r15208 - gnucash/trunk/lib/libqof/qof - Check for return value of regcomp() and return NULL on failure, as suggested by Jon Arney.

Christian Stimming cstim at cvs.gnucash.org
Tue Dec 12 06:33:04 EST 2006


Author: cstim
Date: 2006-12-12 06:33:03 -0500 (Tue, 12 Dec 2006)
New Revision: 15208
Trac: http://svn.gnucash.org/trac/changeset/15208

Modified:
   gnucash/trunk/lib/libqof/qof/qofquerycore.c
Log:
Check for return value of regcomp() and return NULL on failure, as suggested by Jon Arney.

Modified: gnucash/trunk/lib/libqof/qof/qofquerycore.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofquerycore.c	2006-12-12 11:28:08 UTC (rev 15207)
+++ gnucash/trunk/lib/libqof/qof/qofquerycore.c	2006-12-12 11:33:03 UTC (rev 15208)
@@ -257,6 +257,7 @@
                             gboolean is_regex)
 {
   query_string_t pdata;
+  int rc;
 
   g_return_val_if_fail (str, NULL);
   g_return_val_if_fail (*str != '\0', NULL);
@@ -273,7 +274,12 @@
     if (options == QOF_STRING_MATCH_CASEINSENSITIVE)
       flags |= REG_ICASE;
 
-    regcomp(&pdata->compiled, str, flags);
+    rc = regcomp(&pdata->compiled, str, flags);
+    if (rc) {
+	g_free(pdata->matchstring);
+	g_free(pdata);
+	return NULL;
+    }
     pdata->is_regex = TRUE;
   }
 



More information about the gnucash-changes mailing list