]> granicus.if.org Git - curl/commitdiff
curl: fix memory leak reading --writeout from file
authorDaniel Stenberg <daniel@haxx.se>
Fri, 30 Nov 2018 10:59:04 +0000 (11:59 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 30 Nov 2018 21:48:09 +0000 (22:48 +0100)
If another string had been set first, the writout function for reading
the syntax from file would leak the previously allocated memory.

Reported-by: Brian Carpenter
Fixes #3322
Closes #3330

src/tool_getparam.c

index cd21f774cd091b6aeb410ae9beb1ebc12e7102c3..c0d3a84f236dd75f70a3b65d1146bc4599264fa5 100644 (file)
@@ -2066,6 +2066,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
           fname = nextarg;
           file = fopen(nextarg, FOPEN_READTEXT);
         }
+        Curl_safefree(config->writeout);
         err = file2string(&config->writeout, file);
         if(file && (file != stdin))
           fclose(file);