libFLAC/bitreader.c: Fix shift invoking undefined behaviour

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18589
Testcase: fuzzer_decoder-5668806471188480
This commit is contained in:
Erik de Castro Lopo 2019-11-11 06:42:11 +11:00
parent c7d3bd80cf
commit b3f55c40cc
1 changed files with 1 additions and 1 deletions

View File

@ -462,7 +462,7 @@ FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val,
return false;
/* sign-extend *val assuming it is currently bits wide. */
/* From: https://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */
mask = 1u << (bits - 1);
mask = bits >= 33 ? 0 : 1u << (bits - 1);
*val = (uval ^ mask) - mask;
return true;
}