]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Handling memory leak and potential side effect
authorBimba Shrestha <bimbashrestha@fb.com>
Mon, 16 Sep 2019 20:35:45 +0000 (13:35 -0700)
committerBimba Shrestha <bimbashrestha@fb.com>
Mon, 16 Sep 2019 20:35:45 +0000 (13:35 -0700)
tests/fuzzer.c

index fdf6960bc12c86e3568cb9ce7af9fbf07118ee0a..b11a3cc06847948a3aecd83990223bd02a2433f5 100644 (file)
@@ -1960,10 +1960,15 @@ static int basicUnitTests(U32 const seed, double compressibility)
         DISPLAYLEVEL(3, "OK \n");
     }
 
-    DISPLAYLEVEL(3, "test%3i : ZSTD_getSequences zeros : ", testNb++);
-    memset(CNBuffer, 0, 1000000);
-    assert(ZSTD_getSequences(ZSTD_createCCtx(), compressedBuffer, 1000000,
-        CNBuffer, 1000000) == 1000000 / 131071 + 1);
+    {
+        ZSTD_CCtx* cctx = ZSTD_createCCtx();
+        assert(cctx != NULL);
+        DISPLAYLEVEL(3, "test%3i : ZSTD_getSequences zeros : ", testNb++);
+        memset(CNBuffer, 0, 1000000);
+        assert(ZSTD_getSequences(cctx, compressedBuffer, 1000000,
+            CNBuffer, 1000000) == 1000000 / 131071 + 1);
+        ZSTD_freeCCtx(cctx);
+    }
 
     /* All zeroes test (test bug #137) */
     #define ZEROESLENGTH 100