]> granicus.if.org Git - curl/commitdiff
fix a (minor) memory leak in case of error
authorDaniel Stenberg <daniel@haxx.se>
Sat, 31 Mar 2007 21:15:37 +0000 (21:15 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 31 Mar 2007 21:15:37 +0000 (21:15 +0000)
CID 21 in the coverity.com scan

src/main.c

index b4b3bfd8d9237748b1cbc21ba3a6c748e00240f1..cfec4a307c3a722a2356382bb05ed109922173e7 100644 (file)
@@ -2052,8 +2052,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
           char *oldpost=config->postfields;
           size_t newlen = strlen(oldpost) + strlen(postdata) + 2;
           config->postfields=malloc(newlen);
-          if(!config->postfields)
+          if(!config->postfields) {
+            free(postdata);
             return PARAM_NO_MEM;
+          }
           /* use ASCII value 0x26 for '&' to accommodate non-ASCII platforms */
           snprintf(config->postfields, newlen, "%s\x26%s", oldpost, postdata);
           free(oldpost);