summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2023-02-20 18:35:13 +0100
committerDaniel Stenberg <daniel@haxx.se>2023-02-21 10:34:29 +0100
commit1c9cfb7af368feefb522caf81b052ee742a76da8 (patch)
tree98323bb4e10566c95cae66828ebab7a1e1f54b47 /src
parent0cafff2e5fef33b4d1013ab5c7cc68a782c17f66 (diff)
downloadcurl-1c9cfb7af368feefb522caf81b052ee742a76da8.tar.gz
tool_operate: avoid fclose(NULL) on bad header dump file
Fixes #10570 Reported-by: Jérémy Rabasco Closes #10571
Diffstat (limited to 'src')
-rw-r--r--src/tool_operate.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 195159229..cec24057a 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -984,12 +984,13 @@ static CURLcode single_transfer(struct GlobalConfig *global,
*/
if(!per->prev || per->prev->config != config) {
newfile = fopen(config->headerfile, "wb+");
- fclose(newfile);
+ if(newfile)
+ fclose(newfile);
}
newfile = fopen(config->headerfile, "ab+");
if(!newfile) {
- warnf(global, "Failed to open %s\n", config->headerfile);
+ errorf(global, "Failed to open %s\n", config->headerfile);
result = CURLE_WRITE_ERROR;
break;
}