| https://github.com/curl/curl/commit/1c9cfb7af368feefb522caf81b052ee742a76da8 |
| From: Daniel Stenberg <daniel@haxx.se> |
| Date: Mon, 20 Feb 2023 18:35:13 +0100 |
| Subject: [PATCH] tool_operate: avoid fclose(NULL) on bad header dump file |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| Fixes #10570 |
| Reported-by: Jérémy Rabasco |
| Closes #10571 |
| --- 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; |
| } |