--- libogg-1.1/src/bitwise.c.orig 2003-12-07 01:48:17.000000000 +0100 +++ libogg-1.1/src/bitwise.c 2003-12-07 01:52:58.000000000 +0100 @@ -251,7 +251,8 @@ long oggpack_look(oggpack_buffer *b,int /* Read in bits without advancing the bitptr; bits <= 32 */ long oggpackB_look(oggpack_buffer *b,int bits){ unsigned long ret; - int m=32-bits; + unsigned long m=mask[bits]; + int s=32-bits; bits+=b->endbit; @@ -272,7 +273,7 @@ long oggpackB_look(oggpack_buffer *b,int } } } - return (ret>>(m>>1))>>((m+1)>>1); + return ((ret>>(s>>1))>>((s+1)>>1)&m); } long oggpack_look1(oggpack_buffer *b){ @@ -347,7 +348,8 @@ long oggpack_read(oggpack_buffer *b,int /* bits <= 32 */ long oggpackB_read(oggpack_buffer *b,int bits){ unsigned long ret; - long m=32-bits; + unsigned long m=mask[bits]; + long s=32-bits; bits+=b->endbit; @@ -369,7 +371,7 @@ long oggpackB_read(oggpack_buffer *b,int } } } - ret=(ret>>(m>>1))>>((m+1)>>1); + ret=((ret>>(s>>1))>>((s+1)>>1)&m); overflow: