Unverified Commit 6e054623 authored by Daniel Gustafsson's avatar Daniel Gustafsson Committed by Daniel Stenberg
Browse files

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
parent c3654df1
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1504,10 +1504,9 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
    format_ptr = get_netscape_format(array[i]);
    if(format_ptr == NULL) {
      fprintf(out, "#\n# Fatal libcurl error\n");
      if(!use_stdout) {
      free(array);
      if(!use_stdout)
        fclose(out);
      }
      return 1;
    }
    fprintf(out, "%s\n", format_ptr);