diff --git a/libFDK/include/FDK_bitstream.h b/libFDK/include/FDK_bitstream.h index d47a750..19bc864 100644 --- a/libFDK/include/FDK_bitstream.h +++ b/libFDK/include/FDK_bitstream.h @@ -277,11 +277,15 @@ FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream) hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf); hBitStream->BitsInCache = CACHE_BITS; } - else + else if (validBits > 0) { hBitStream->CacheWord = FDK_get (&hBitStream->hBitBuf,validBits); hBitStream->BitsInCache = validBits; } + else + { + return 0; + } } hBitStream->BitsInCache--;