From 697b603ed11356c2f866438704a63bafa7117d17 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Sat, 26 May 2001 05:19:10 +0000 Subject: [PATCH] fix bug in inlined version of FLAC__bitbuffer_read_raw_int32 where sign extension was not done in some cases --- src/libFLAC/bitbuffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libFLAC/bitbuffer.c b/src/libFLAC/bitbuffer.c index 6ec34c9..0a9645d 100644 --- a/src/libFLAC/bitbuffer.c +++ b/src/libFLAC/bitbuffer.c @@ -1168,7 +1168,11 @@ bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, int32 *val, const unsig /* we hold off updating bb->total_consumed_bits until the end */ } else { - *val = (bb->buffer[bb->consumed_bytes] & (0xff >> bb->consumed_bits)) >> (i-bits_); + /* bits_ must be < 7 if we get to here */ + v = (bb->buffer[bb->consumed_bytes] & (0xff >> bb->consumed_bits)); + v <<= (32-i); + *val = (int32)v; + *val >>= (32-bits_); bb->consumed_bits += bits_; bb->total_consumed_bits += bits_; return true; -- 2.7.4