summaryrefslogtreecommitdiff
path: root/src/bitwise.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bitwise.c')
-rw-r--r--src/bitwise.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bitwise.c b/src/bitwise.c
index 83627e9..380119e 100644
--- a/src/bitwise.c
+++ b/src/bitwise.c
@@ -355,6 +355,9 @@ long oggpackB_read(oggpack_buffer *b,int bits){
/* not the main path */
ret=-1L;
if(b->endbyte*8+bits>b->storage*8)goto overflow;
+ /* special case to avoid reading b->ptr[0], which might be past the end of
+ the buffer; also skips some useless accounting */
+ else if(!bits)return(0L);
}
ret=b->ptr[0]<<(24+b->endbit);