avcodec/j2kenc: Fix out of array access in encode_cblk()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 30 Nov 2017 22:42:04 +0000 (23:42 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 1 Dec 2017 22:12:07 +0000 (23:12 +0100)
Fixes: 4427/clusterfuzz-testcase-minimized-5106919271301120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/j2kenc.c

index 32c7fdd..78ec88a 100644 (file)
@@ -690,7 +690,8 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
     cblk->npasses = passno;
     cblk->ninclpasses = passno;
 
-    cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
+    if (passno)
+        cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
 }
 
 /* tier-2 routines: */