Changeset: f00e5a515b79 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f00e5a515b79
Modified Files:
        monetdb5/modules/mal/pcre.c
Branch: Aug2011
Log Message:

Deal properly with "free"ing NULL pointers.
We use pcre_study() to improve matching.  When we're done, we free the
result of pcre_study() using a call to my_pcre_free().
pcre_study() may return NULL if no state is needed for optimization of
the search pattern.  Since we just pass the result of pcre_study()
around to other pcre functions, we don't really care about the result,
but we do have to free the memory by calling my_pcre_free.
However, my_pcre_free couldn't deal with NULL pointers, which caused a
crash.
We now check for NULL pointers in my_pcre_free.
This fixes bug 2869.


diffs (16 lines):

diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -319,8 +319,11 @@ my_pcre_malloc(size_t s)
 static void
 my_pcre_free(void *blk)
 {
-       size_t *sz = (size_t *) blk;
+       size_t *sz;
 
+       if (blk == NULL)
+               return;
+       sz = (size_t *) blk;
        sz -= 1;
        GDKfree(sz);
 }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to