diff mbox series

[FFmpeg-devel,4/6] avcodec/escape124: Check that blocks are allocated before use

Message ID 20230409142627.19820-4-michael@niedermayer.cc
State Accepted
Commit 5366ae12b9ba60404822f6b39b41f6c0d98a7c8a
Headers show
Series [FFmpeg-devel,1/6] avcodec/huffyuvdec: Fix undefined behavior with shift | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer April 9, 2023, 2:26 p.m. UTC
Fixes: NULL pointer dereference
Fixes: 57819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE124_fuzzer-5077280228769792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/escape124.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c
index e8a8395f4b1..592de09a9fd 100644
--- a/libavcodec/escape124.c
+++ b/libavcodec/escape124.c
@@ -155,7 +155,7 @@  static MacroBlock decode_macroblock(Escape124Context* s, GetBitContext* gb,
 
     // This condition can occur with invalid bitstreams and
     // *codebook_index == 2
-    if (block_index >= s->codebooks[*codebook_index].size)
+    if (block_index >= s->codebooks[*codebook_index].size || !s->codebooks[*codebook_index].blocks)
         return (MacroBlock) { { 0 } };
 
     return s->codebooks[*codebook_index].blocks[block_index];