Skip to content

Commit 118200f

Browse files
authored
Merge pull request #3677 from facebook/detectOverflow
Changed the decoding loop to detect more invalid cases of corruption sooner
2 parents 2582234 + c123e69 commit 118200f

File tree

2 files changed

+73
-86
lines changed

2 files changed

+73
-86
lines changed

lib/common/bitstream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
411411
FORCE_INLINE_TEMPLATE BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
412412
{
413413
/* note : once in overflow mode, a bitstream remains in this mode until it's reset */
414-
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) {
414+
if (UNLIKELY(bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))) {
415415
static const BitContainerType zeroFilled = 0;
416416
bitD->ptr = (const char*)&zeroFilled; /* aliasing is allowed for char */
417417
/* overflow detected, erroneous scenario or end of stream: no update */

0 commit comments

Comments
 (0)