OSSP CVS Repository

ossp - Difference in ossp-pkg/str/str_parse.c versions 1.15 and 1.16
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/str/str_parse.c 1.15 -> 1.16

--- str_parse.c  2001/08/28 10:38:44     1.15
+++ str_parse.c  2001/09/11 11:39:28     1.16
@@ -270,8 +270,8 @@
 }
 int str_parse_va(const char *string, const char *pattern, va_list ap)
 {
-    pcre *p_pcre;
-    pcre_extra *p_pcre_extra;
+    pcre *p_pcre = NULL;
+    pcre_extra *p_pcre_extra = NULL;
     const char *match_ptr; 
     int match_len;
     int match_opt;
@@ -417,10 +417,10 @@
     if (cap_num > 0) {
         cap_len = (cap_num+1)*3;
         if ((cap_vec = (int *)malloc(cap_len*sizeof(int))) == NULL) {
-            if (!match_once) {
+            if (p_pcre != NULL)
                 free(p_pcre);
+            if (p_pcre_extra != NULL)
                 free(p_pcre_extra);
-            }
             return -1;
         }
     }
@@ -432,10 +432,10 @@
     if (n < 0) {
         if (cap_vec != NULL)
             free(cap_vec);
-        if (!match_once) {
+        if (p_pcre != NULL)
             free(p_pcre);
+        if (p_pcre_extra != NULL)
             free(p_pcre_extra);
-        }
         if (n == PCRE_ERROR_NOMATCH)
             return 0;
         return -1;
@@ -566,8 +566,13 @@
         l = str_vformat(&sf, buf_ptr, ap);
 
         /* allocate output buffer */
-        if ((*cpp = (char *)malloc(l+1)) == NULL)
+        if ((*cpp = (char *)malloc(l+1)) == NULL) {
+            if (p_pcre != NULL)
+                free(p_pcre);
+            if (p_pcre_extra != NULL)
+                free(p_pcre_extra);
             return -1; /* XXX */
+        }
 
         /* finally expand the substitutions string into output buffer */
         sf.curpos    = *cpp;
@@ -588,10 +593,10 @@
     /* cleanup */
     if (cap_vec != NULL)
         free(cap_vec);
-    if (!match_once) {
+    if (p_pcre != NULL)
         free(p_pcre);
+    if (p_pcre_extra != NULL)
         free(p_pcre_extra);
-    }
     /* return success */
     return 1;
 }

CVSTrac 2.0.1