aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-03-08 15:18:03 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-03-08 15:18:03 +0000
commitd9459b54d9c79267fd02e989ae3e86bdc4e8a983 (patch)
treedf69593297c2e717ad9813f3b2066f60c29006f5 /src
parent017be8a882113c5414ac283266491ca8035c0092 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 4d30a2c80..885a515ee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -455,6 +455,7 @@ struct Configurable {
char *writeout; /* %-styled format string to output */
FILE *errors; /* if stderr redirect is requested */
+ bool errors_fopened;
struct curl_slist *quote;
struct curl_slist *postquote;
@@ -1031,8 +1032,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->crlf = TRUE;
break;
case '8': /* there is no short letter for this */
- if(strcmp(nextarg, "-"))
+ if(strcmp(nextarg, "-")) {
config->errors = fopen(nextarg, "wt");
+ config->errors_fopened = TRUE;
+ }
else
config->errors = stdout;
break;
@@ -2487,9 +2490,7 @@ operate(struct Configurable *config, int argc, char *argv[])
/* cleanup the curl handle! */
curl_easy_cleanup(curl);
- if((config->errors != stderr) &&
- (config->errors != stdout))
- /* it wasn't directed to stdout or stderr so close the file! */
+ if(config->errors_fopened)
fclose(config->errors);
main_free(); /* cleanup */