]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Rearranging assert and allowing 4 extra for FSE_BLOCKBOUND()
authorBimba Shrestha <bimbashrestha@fb.com>
Thu, 12 Sep 2019 21:43:50 +0000 (14:43 -0700)
committerBimba Shrestha <bimbashrestha@fb.com>
Thu, 12 Sep 2019 21:43:50 +0000 (14:43 -0700)
contrib/linux-kernel/lib/zstd/fse.h
lib/common/bitstream.h

index 7460ab04b1916db01f23d243b2eb226b7a694a10..a694199fdfd15acaf24eabad1eb1d4acf4c536e4 100644 (file)
@@ -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 */
index 7bdb060460dce96605e08af969d81e95aa2a1825..fb10cca361aba3f8bf5de2aaab61d4e1b39786c3 100644 (file)
@@ -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;
 }