From 1d803d8deb4b275ea6d43264ad5313d0acc463c5 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 1 Apr 2016 18:57:41 +0200 Subject: [PATCH] fixed zbuff error 775-3 (internal buffer management) --- lib/zbuff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/zbuff.c b/lib/zbuff.c index 1027c697..06a7ec4e 100644 --- a/lib/zbuff.c +++ b/lib/zbuff.c @@ -135,8 +135,9 @@ size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc, free(zbc->inBuff); /* should not be necessary */ zbc->inBuff = (char*)malloc(neededInBuffSize); if (zbc->inBuff == NULL) return ERROR(memory_allocation); - } } - zbc->blockSize = MIN(ZSTD_BLOCKSIZE_MAX, zbc->inBuffSize); + } + zbc->blockSize = MIN(ZSTD_BLOCKSIZE_MAX, neededInBuffSize); + } if (zbc->outBuffSize < ZSTD_compressBound(zbc->blockSize)+1) { zbc->outBuffSize = ZSTD_compressBound(zbc->blockSize)+1; free(zbc->outBuff); /* should not be necessary */