]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed memory leak
authorYann Collet <cyan@fb.com>
Thu, 15 Sep 2016 15:02:06 +0000 (17:02 +0200)
committerYann Collet <cyan@fb.com>
Thu, 15 Sep 2016 15:02:06 +0000 (17:02 +0200)
lib/compress/zstd_compress.c
programs/datagen.c
programs/fileio.h

index df8201beb4df2cbaaf9a41c7266f9703e67f57de..f5b712fc36d66bf03aaac53849155bd7f1854ec8 100644 (file)
@@ -2817,6 +2817,7 @@ size_t ZSTD_freeCStream(ZSTD_CStream* zcs)
     if (zcs==NULL) return 0;   /* support free on NULL */
     {   ZSTD_customMem const cMem = zcs->customMem;
         ZSTD_freeCCtx(zcs->cctx);
+        ZSTD_freeCDict(zcs->cdict);
         ZSTD_free(zcs->inBuff, cMem);
         ZSTD_free(zcs->outBuff, cMem);
         ZSTD_free(zcs, cMem);
index 109b8e3d8817200cf9d8fc00d39e866921d0b7d6..1af5a38a58582e86480b7c0b13af530ed75ef50a 100644 (file)
 /*-************************************
 *  Dependencies
 **************************************/
-#include <stdlib.h>    /* malloc */
+#include <stdlib.h>    /* malloc, free */
 #include <stdio.h>     /* FILE, fwrite, fprintf */
 #include <string.h>    /* memcpy */
-#include <errno.h>     /* errno */
 #include "mem.h"       /* U32 */
 
 
@@ -176,7 +175,7 @@ void RDG_genStdout(unsigned long long size, double matchProba, double litProba,
     BYTE ldt[LTSIZE];   /* literals distribution table */
 
     /* init */
-    if (buff==NULL) { fprintf(stderr, "datagen: error: %s \n", strerror(errno)); exit(1); }
+    if (buff==NULL) { perror("datagen"); exit(1); }
     if (litProba<=0.0) litProba = matchProba / 4.5;
     memset(ldt, '0', sizeof(ldt));   /* yes, character '0', this is intentional */
     RDG_fillLiteralDistrib(ldt, litProba);
index 9cf6c96fc267472c3a8239f052ba3176456a77e5..1e89aec2781c6c3ec0020456df27d96f871ab1d2 100644 (file)
@@ -8,7 +8,8 @@
  */
 
 
-#pragma once
+#ifndef FILEIO_H_23981798732
+#define FILEIO_H_23981798732
 
 #if defined (__cplusplus)
 extern "C" {
@@ -69,3 +70,5 @@ int FIO_decompressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles
 #if defined (__cplusplus)
 }
 #endif
+
+#endif  /* FILEIO_H_23981798732 */