aboutsummaryrefslogtreecommitdiffstats
path: root/libFDK/include/FDK_bitstream.h
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2017-08-03 13:47:15 +0300
committerMartin Storsjo <martin@martin.st>2017-08-03 14:22:30 +0300
commit52c2660c26beaaccf903759c18bb758e9f18a470 (patch)
tree36f3e9073994bae616fa99f105520213ab4c3b9b /libFDK/include/FDK_bitstream.h
parentecb2ad9a7b72b9fe96720c59289e5ccd9bf0f433 (diff)
downloadfdk-aac-52c2660c26beaaccf903759c18bb758e9f18a470.tar.gz
fdk-aac-52c2660c26beaaccf903759c18bb758e9f18a470.tar.bz2
fdk-aac-52c2660c26beaaccf903759c18bb758e9f18a470.zip
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
Diffstat (limited to 'libFDK/include/FDK_bitstream.h')
-rw-r--r--libFDK/include/FDK_bitstream.h6
1 files changed, 5 insertions, 1 deletions
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--;