diff mbox

[FFmpeg-devel,2/3] avcodec/j2kenc: Fix out of array access in encode_cblk()

Message ID 20171130225811.13103-2-michael@niedermayer.cc
State Accepted
Commit 0674087004538599797688785f6ac82358abc23b
Headers show

Commit Message

Michael Niedermayer Nov. 30, 2017, 10:58 p.m. UTC
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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 32c7fddb74..78ec88a694 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -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: */