tool_operate: avoid fclose(NULL) on bad header dump file

Fixes #10570
Reported-by: Jérémy Rabasco
Closes #10571
This commit is contained in:
Daniel Stenberg 2023-02-20 18:35:13 +01:00
parent 0cafff2e5f
commit 1c9cfb7af3
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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;
}