From 35db5bc8356c70ccba36bcf4a851ce11b0e84e69 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 15 Oct 2019 11:20:53 -0300 Subject: [PATCH] lz4: fix potential div by zero Summary: LZ4F_getBlockSize() can return 0 CID 1404010 Reviewers: lauromoura Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10392 --- src/static_libs/lz4/lz4frame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static_libs/lz4/lz4frame.c b/src/static_libs/lz4/lz4frame.c index a10e4af..95da80e 100644 --- a/src/static_libs/lz4/lz4frame.c +++ b/src/static_libs/lz4/lz4frame.c @@ -334,7 +334,7 @@ static size_t LZ4F_compressBound_internal(size_t srcSize, size_t const maxBuffered = blockSize - 1; size_t const bufferedSize = MIN(alreadyBuffered, maxBuffered); size_t const maxSrcSize = srcSize + bufferedSize; - unsigned const nbFullBlocks = (unsigned)(maxSrcSize / blockSize); + unsigned const nbFullBlocks = blockSize ? (unsigned)(maxSrcSize / blockSize) : 0; size_t const partialBlockSize = maxSrcSize & (blockSize-1); size_t const lastBlockSize = flush ? partialBlockSize : 0; unsigned const nbBlocks = nbFullBlocks + (lastBlockSize>0); -- 2.7.4