From 28773f3faa2cb006bebb39d84b8fe9d9823028d0 Mon Sep 17 00:00:00 2001 From: Svyatoslav Krasnov Date: Thu, 21 Jul 2022 12:29:42 +0000 Subject: [PATCH] fix gz resource leakage --- tools/stage_file_native.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/stage_file_native.cpp b/tools/stage_file_native.cpp index 6b1a514c7b..2568b5e7e9 100644 --- a/tools/stage_file_native.cpp +++ b/tools/stage_file_native.cpp @@ -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); }