]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fixed buf resource leak in gz_compress when USE_MMAP is defined. (CID 298965)
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 13 Sep 2020 04:20:36 +0000 (21:20 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 14 Sep 2020 10:05:13 +0000 (12:05 +0200)
test/minigzip.c

index da45d48cc3fcf9132ba8e6cd4c3f25bc580468b7..bf95bd324de9dc80bbee8cce639f4b0e86246c6c 100644 (file)
@@ -90,7 +90,7 @@ void error(const char *msg) {
  */
 
 void gz_compress(FILE *in, gzFile out) {
-    char *buf = (char *)calloc(BUFLEN, 1);
+    char *buf;
     int len;
     int err;
 
@@ -100,6 +100,7 @@ void gz_compress(FILE *in, gzFile out) {
      */
     if (gz_compress_mmap(in, out) == Z_OK) return;
 #endif
+    buf = (char *)calloc(BUFLEN, 1);
     for (;;) {
         len = (int)fread(buf, 1, BUFLEN, in);
         if (ferror(in)) {