Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 May 2017 19:56:43 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317700 - head/usr.bin/grep/regex
Message-ID:  <201705021956.v42JuhSu037351@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue May  2 19:56:42 2017
New Revision: 317700
URL: https://svnweb.freebsd.org/changeset/base/317700

Log:
  bsdgrep: use calloc where appropriate in grep's tre-fastmatch
  
  Also apply style(9) to a related NULL check.
  
  Submitted by:	Kyle Evans <kevans91 at ksu.edu> (D10098)

Modified:
  head/usr.bin/grep/regex/tre-fastmatch.c

Modified: head/usr.bin/grep/regex/tre-fastmatch.c
==============================================================================
--- head/usr.bin/grep/regex/tre-fastmatch.c	Tue May  2 19:30:42 2017	(r317699)
+++ head/usr.bin/grep/regex/tre-fastmatch.c	Tue May  2 19:56:42 2017	(r317700)
@@ -630,7 +630,7 @@ tre_compile_fast(fastmatch_t *fg, const 
 	    if (escaped)
 	      {
 		if (!_escmap)
-		  _escmap = malloc(n * sizeof(bool));
+		  _escmap = calloc(n, sizeof(bool));
 		if (!_escmap)
 		  {
 		    free(tmp);
@@ -714,8 +714,8 @@ badpat:
     {
       if (fg->wescmap != NULL)
 	{
-	  fg->escmap = malloc(fg->len * sizeof(bool));
-	  if (!fg->escmap)
+	  fg->escmap = calloc(fg->len, sizeof(bool));
+	  if (fg->escmap != NULL)
 	    {
 	      tre_free_fast(fg);
 	      return REG_ESPACE;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705021956.v42JuhSu037351>