grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.6.3-30-g190026c


From: Jim Meyering
Subject: grep branch, master, updated. v2.6.3-30-g190026c
Date: Wed, 07 Apr 2010 12:59:41 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  190026cc9551a02096db4a91a5efc2a6c8c9ed41 (commit)
      from  488112fc96510ab5e8940b350b3ae0f150a02ccb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=190026cc9551a02096db4a91a5efc2a6c8c9ed41


commit 190026cc9551a02096db4a91a5efc2a6c8c9ed41
Author: Jim Meyering <address@hidden>
Date:   Thu Apr 1 15:44:06 2010 +0200

    mbtolower: avoid potential NULL-dereference
    
    * src/searchutils.c: Include <assert.h>.
    (mbtolower): Assert that 0 < *n, to avoid possibility of NULL-deref.
    Remove dead increment.

diff --git a/src/searchutils.c b/src/searchutils.c
index d8321e7..ee7d9ae 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -17,6 +17,7 @@
    02110-1301, USA.  */
 
 #include <config.h>
+#include <assert.h>
 #include "search.h"
 
 #define NCHAR (UCHAR_MAX + 1)
@@ -51,6 +52,7 @@ kwsinit (kwset_t *kwset)
    to the length (in bytes) of the resulting string (not including the
    trailing NUL byte), and return a pointer to the lowercase string.
    Upon memory allocation failure, this function exits.
+   Note that on input, *N must be larger than zero.
 
    Note that while this function returns a pointer to malloc'd storage,
    the caller must not free it, since this function retains a pointer
@@ -66,11 +68,15 @@ mbtolower (const char *beg, size_t *n)
   const char *end;
   char *p;
 
+  assert (0 < *n);
+
   if (*n > outalloc)
     {
       out = xrealloc (out, *n);
       outalloc = *n;
     }
+  /* appease clang-2.6 */
+  assert (out);
 
   memset (&is, 0, sizeof (is));
   memset (&os, 0, sizeof (os));
@@ -108,7 +114,7 @@ mbtolower (const char *beg, size_t *n)
     }
 
   *n = p - out;
-  *p++ = 0;
+  *p = 0;
   return out;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/searchutils.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep




reply via email to

[Prev in Thread] Current Thread [Next in Thread]