libFLAC/bitreader.c: Fix shift invoking undefined behaviour
Credit: Oss-Fuzz Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19036 Testcase: fuzzer_decoder-5679084202098688
This commit is contained in:
parent
f706f28322
commit
d518e13a1f
@ -415,8 +415,9 @@ FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *va
|
||||
br->consumed_words++;
|
||||
br->consumed_bits = 0;
|
||||
if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
|
||||
*val = bits >= 32 ? 0 : *val << bits ;
|
||||
*val |= (FLAC__uint32)(br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
|
||||
uint32_t shift = FLAC__BITS_PER_WORD - bits;
|
||||
*val = bits < 32 ? *val << bits : 0;
|
||||
*val |= shift < FLAC__BITS_PER_WORD ? (FLAC__uint32)(br->buffer[br->consumed_words] >> shift) : 0;
|
||||
br->consumed_bits = bits;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user