Make sure at least one bit exists before reading further in FDKreadBit

Fixes: 2709/clusterfuzz-testcase-minimized-6160249369133056

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
This commit is contained in:
Martin Storsjo 2017-08-03 13:47:15 +03:00
parent ecb2ad9a7b
commit 52c2660c26
1 changed files with 5 additions and 1 deletions

View File

@ -277,11 +277,15 @@ FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream)
hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf); hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf);
hBitStream->BitsInCache = CACHE_BITS; hBitStream->BitsInCache = CACHE_BITS;
} }
else else if (validBits > 0)
{ {
hBitStream->CacheWord = FDK_get (&hBitStream->hBitBuf,validBits); hBitStream->CacheWord = FDK_get (&hBitStream->hBitBuf,validBits);
hBitStream->BitsInCache = validBits; hBitStream->BitsInCache = validBits;
} }
else
{
return 0;
}
} }
hBitStream->BitsInCache--; hBitStream->BitsInCache--;