From a6bdf55759a9b28cd20d10434604625f91b9b7b9 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 15 Sep 2016 17:02:06 +0200 Subject: [PATCH] fixed memory leak --- lib/compress/zstd_compress.c | 1 + programs/datagen.c | 5 ++--- programs/fileio.h | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index df8201be..f5b712fc 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -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); diff --git a/programs/datagen.c b/programs/datagen.c index 109b8e3d..1af5a38a 100644 --- a/programs/datagen.c +++ b/programs/datagen.c @@ -20,10 +20,9 @@ /*-************************************ * Dependencies **************************************/ -#include /* malloc */ +#include /* malloc, free */ #include /* FILE, fwrite, fprintf */ #include /* memcpy */ -#include /* 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); diff --git a/programs/fileio.h b/programs/fileio.h index 9cf6c96f..1e89aec2 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -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 */