mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 00:58:48 -05:00
cookies: fix leak when writing cookies to file
If the formatting fails, we error out on a fatal error and clean up on the way out. The array was however freed within the wrong scope and was thus never freed in case the cookies were written to a file instead of STDOUT. Closes #2957
This commit is contained in:
parent
c3654df166
commit
6e054623b4
@ -1504,10 +1504,9 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
|
|||||||
format_ptr = get_netscape_format(array[i]);
|
format_ptr = get_netscape_format(array[i]);
|
||||||
if(format_ptr == NULL) {
|
if(format_ptr == NULL) {
|
||||||
fprintf(out, "#\n# Fatal libcurl error\n");
|
fprintf(out, "#\n# Fatal libcurl error\n");
|
||||||
if(!use_stdout) {
|
free(array);
|
||||||
free(array);
|
if(!use_stdout)
|
||||||
fclose(out);
|
fclose(out);
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fprintf(out, "%s\n", format_ptr);
|
fprintf(out, "%s\n", format_ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user