Commit da6b29b5 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Henrik Gramner

Fix possible undefined behavior of right shift

32-bit shifts are only defined for values in the range 0-31.
parent 7e457290
......@@ -89,8 +89,13 @@ static inline void bs_init( bs_t *s, void *p_data, int i_data )
s->p = s->p_start = (uint8_t*)p_data - offset;
s->p_end = (uint8_t*)p_data + i_data;
s->i_left = (WORD_SIZE - offset)*8;
s->cur_bits = endian_fix32( M32(s->p) );
s->cur_bits >>= (4-offset)*8;
if( offset )
{
s->cur_bits = endian_fix32( M32(s->p) );
s->cur_bits >>= (4-offset)*8;
}
else
s->cur_bits = 0;
}
static inline int bs_pos( bs_t *s )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment