diff mbox series

[FFmpeg-devel,1/3] libavcodec/jpeg2000: fix cblk decode error check

Message ID 20200411064009.5321-1-gautamramk@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] libavcodec/jpeg2000: fix cblk decode error check
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Gautam Ramakrishnan April 11, 2020, 6:40 a.m. UTC
From: Gautam Ramakrishnan <gautamramk@gmail.com>

bpno becoming negative is not an error. This check has
been verified with openjpeg, where the loop ends safely
when bpno becomes negative, instead of returning an error.
This patch must resolve ticket #5630.
---
 libavcodec/jpeg2000dec.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9684e57b34..2f6bdeb6e0 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1622,11 +1622,7 @@  static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
     cblk->data[cblk->length+1] = 0xff;
     ff_mqc_initdec(&t1->mqc, cblk->data, 0, 1);
 
-    while (passno--) {
-        if (bpno < 0) {
-            av_log(s->avctx, AV_LOG_ERROR, "bpno became negative\n");
-            return AVERROR_INVALIDDATA;
-        }
+    while (passno-- && bpno >= 0) {
         switch(pass_t) {
         case 0:
             decode_sigpass(t1, width, height, bpno + 1, bandpos,