]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: avoid fclose(NULL) on bad header dump file
authorDaniel Stenberg <daniel@haxx.se>
Mon, 20 Feb 2023 17:35:13 +0000 (18:35 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 21 Feb 2023 09:34:29 +0000 (10:34 +0100)
Fixes #10570
Reported-by: Jérémy Rabasco
Closes #10571

src/tool_operate.c

index 195159229af660228c56335f1b8c1576dd085198..cec24057a6cbcac0fcd5f284f55840311e825d18 100644 (file)
@@ -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;
             }