From: Michael Niedermayer <[email protected]>

Fixes out of array access

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/jpeg2000dec.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 690a79c..3908146 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1226,9 +1226,16 @@ static int 
jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
         oldpos = bytestream2_tell(&s->g);
 
         if (marker == JPEG2000_SOD) {
-            Jpeg2000Tile *tile = s->tile + s->curtileno;
-            Jpeg2000TilePart *tp = tile->tile_part + tile->tp_idx;
+            Jpeg2000Tile *tile;
+            Jpeg2000TilePart *tp;
 
+            if (s->curtileno < 0) {
+                av_log(s->avctx, AV_LOG_ERROR, "Missing SOT\n");
+                return AVERROR_INVALIDDATA;
+            }
+
+            tile = s->tile + s->curtileno;
+            tp = tile->tile_part + tile->tp_idx;
             bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_end - s->g.buffer);
             bytestream2_skip(&s->g, tp->tp_end - s->g.buffer);
 
-- 
1.8.2.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to