From: Bimba Shrestha Date: Thu, 12 Sep 2019 21:43:50 +0000 (-0700) Subject: Rearranging assert and allowing 4 extra for FSE_BLOCKBOUND() X-Git-Tag: v1.4.4~1^2~52^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43da5bf27e707286ba8679c5f10a109b8a3f1447;p=thirdparty%2Fzstd.git Rearranging assert and allowing 4 extra for FSE_BLOCKBOUND() --- diff --git a/contrib/linux-kernel/lib/zstd/fse.h b/contrib/linux-kernel/lib/zstd/fse.h index 7460ab04b..a694199fd 100644 --- a/contrib/linux-kernel/lib/zstd/fse.h +++ b/contrib/linux-kernel/lib/zstd/fse.h @@ -232,7 +232,7 @@ If there is an error, the function will return an error code, which can be teste *******************************************/ /* FSE buffer bounds */ #define FSE_NCOUNTBOUND 512 -#define FSE_BLOCKBOUND(size) (size + (size >> 7)) +#define FSE_BLOCKBOUND(size) (size + (size >> 7) + 4 /* constant for initial fse states */ ) #define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size)) /* Macro version, useful for static allocation */ /* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */ diff --git a/lib/common/bitstream.h b/lib/common/bitstream.h index 7bdb06046..fb10cca36 100644 --- a/lib/common/bitstream.h +++ b/lib/common/bitstream.h @@ -244,9 +244,9 @@ MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC) { size_t const nbBytes = bitC->bitPos >> 3; assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); + assert(bitC->ptr <= bitC->endPtr); MEM_writeLEST(bitC->ptr, bitC->bitContainer); bitC->ptr += nbBytes; - assert(bitC->ptr <= bitC->endPtr); bitC->bitPos &= 7; bitC->bitContainer >>= nbBytes*8; }