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