1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-15 14:05:03 -05:00

cookie: remove redundant check

... as it was already checked previously within the function.

Reported-by: Dmitry-Me
Closes #695
This commit is contained in:
Daniel Stenberg 2016-03-03 21:14:36 +01:00
parent 3c2ef2a610
commit 33a0a926c5

View File

@ -1277,6 +1277,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
struct Cookie *co; struct Cookie *co;
FILE *out; FILE *out;
bool use_stdout=FALSE; bool use_stdout=FALSE;
char *format_ptr;
if((NULL == c) || (0 == c->numcookies)) if((NULL == c) || (0 == c->numcookies))
/* If there are no known cookies, we don't write or even create any /* If there are no known cookies, we don't write or even create any
@ -1297,27 +1298,23 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
return 1; /* failure */ return 1; /* failure */
} }
if(c) { fputs("# Netscape HTTP Cookie File\n"
char *format_ptr; "# https://curl.haxx.se/docs/http-cookies.html\n"
"# This file was generated by libcurl! Edit at your own risk.\n\n",
out);
fputs("# Netscape HTTP Cookie File\n" for(co = c->cookies; co; co = co->next) {
"# https://curl.haxx.se/docs/http-cookies.html\n" if(!co->domain)
"# This file was generated by libcurl! Edit at your own risk.\n\n", continue;
out); format_ptr = get_netscape_format(co);
if(format_ptr == NULL) {
for(co = c->cookies; co; co = co->next) { fprintf(out, "#\n# Fatal libcurl error\n");
if(!co->domain) if(!use_stdout)
continue; fclose(out);
format_ptr = get_netscape_format(co);
if(format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n");
if(!use_stdout)
fclose(out);
return 1; return 1;
}
fprintf(out, "%s\n", format_ptr);
free(format_ptr);
} }
fprintf(out, "%s\n", format_ptr);
free(format_ptr);
} }
if(!use_stdout) if(!use_stdout)