mirror of
https://github.com/moparisthebest/curl
synced 2025-03-01 01:41:50 -05:00
better treatment of the config->errors, only fclose() this if it was
truly fopen()ed. It could end up fclose()ing a NULL as discovered by Clifford Wolf.
This commit is contained in:
parent
017be8a882
commit
d9459b54d9
@ -455,6 +455,7 @@ struct Configurable {
|
|||||||
char *writeout; /* %-styled format string to output */
|
char *writeout; /* %-styled format string to output */
|
||||||
|
|
||||||
FILE *errors; /* if stderr redirect is requested */
|
FILE *errors; /* if stderr redirect is requested */
|
||||||
|
bool errors_fopened;
|
||||||
|
|
||||||
struct curl_slist *quote;
|
struct curl_slist *quote;
|
||||||
struct curl_slist *postquote;
|
struct curl_slist *postquote;
|
||||||
@ -1031,8 +1032,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
config->crlf = TRUE;
|
config->crlf = TRUE;
|
||||||
break;
|
break;
|
||||||
case '8': /* there is no short letter for this */
|
case '8': /* there is no short letter for this */
|
||||||
if(strcmp(nextarg, "-"))
|
if(strcmp(nextarg, "-")) {
|
||||||
config->errors = fopen(nextarg, "wt");
|
config->errors = fopen(nextarg, "wt");
|
||||||
|
config->errors_fopened = TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
config->errors = stdout;
|
config->errors = stdout;
|
||||||
break;
|
break;
|
||||||
@ -2487,9 +2490,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
/* cleanup the curl handle! */
|
/* cleanup the curl handle! */
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
if((config->errors != stderr) &&
|
if(config->errors_fopened)
|
||||||
(config->errors != stdout))
|
|
||||||
/* it wasn't directed to stdout or stderr so close the file! */
|
|
||||||
fclose(config->errors);
|
fclose(config->errors);
|
||||||
|
|
||||||
main_free(); /* cleanup */
|
main_free(); /* cleanup */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user