From: Michael Niedermayer <[email protected]>

Fixes out of array accesses

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

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index b026aab..3b42d9a 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -339,6 +339,11 @@ static int get_cod(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c,
     tmp.nlayers    = bytestream2_get_be16u(&s->g);
     tmp.mct        = bytestream2_get_byteu(&s->g); // multiple component 
transformation
 
+    if (tmp.mct && s->ncomponents < 3) {
+        av_log(s->avctx, "MCT %d with too few components (%d)\n", tmp.mct, 
s->ncomponents);
+        return AVERROR_INVALIDDATA;
+    }
+
     if ((ret = get_cox(s, &tmp)) < 0)
         return ret;
 
-- 
1.8.2.1

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

Reply via email to