Merge pull request #4850 from jellythefish/fix-coverity-tool-issues

fix resource leakage in stage_file in writing to gzip
This commit is contained in:
Vitalii Koshura 2022-07-26 23:21:18 +02:00 committed by GitHub
commit 777f50e3c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -141,15 +141,15 @@ int stage_file(
return -1;
}
int bytes = gzwrite(gz, file_buf.str().c_str(), file_buf.str().size());
if (!bytes) {
fprintf(stderr, "failed to write to gz: %s\n", strerror(errno));
return -1;
}
retval = gzclose(gz);
if (retval != Z_OK) {
fprintf(stderr, "failed to close gz\n");
return retval;
}
if (!bytes) {
fprintf(stderr, "failed to write to gz: %s\n", strerror(errno));
return -1;
}
if (verbose) {
fprintf(stdout, "created .gzip file for %s\n", dl_hier_path);
}