tool_operate: fclose stream only if fopened

Fixes torture test failures
Follow-up to cc71d35265

Closes #7972
This commit is contained in:
Daniel Stenberg 2021-11-08 14:13:30 +01:00
parent ef7c76ad82
commit 9e9fef9e24
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -881,7 +881,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
result = add_per_transfer(&per);
if(result || !curl) {
curl_easy_cleanup(curl);
if(etag_save->stream)
if(etag_save->fopened)
fclose(etag_save->stream);
result = CURLE_OUT_OF_MEMORY;
break;