restored bitMask for shift values

since corrupted bitstreams can generate too large values.

This slightly reduces the benefits from clang on my laptop.
gcc results and code generation are not affected.
dev
Yann Collet 2018-10-10 18:26:44 -07:00
parent c012e9540a
commit 6ed3b526e4
1 changed files with 3 additions and 2 deletions

View File

@ -339,9 +339,10 @@ MEM_STATIC size_t BIT_getUpperBits(size_t bitContainer, U32 const start)
MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
{
U32 const regMask = sizeof(bitContainer)*8 - 1;
/* if start > regMask, bitstream is corrupted, and result is undefined */
assert(nbBits < BIT_MASK_SIZE);
/* if start > bitMask, bitstream is corrupted, and result is undefined */
return (bitContainer >> start) & BIT_mask[nbBits];
return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
}
MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)