avcodec/jpeg2000dec: fix near null pointer dereference
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 18 Aug 2013 16:44:12 +0000 (18:44 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 18 Aug 2013 16:44:12 +0000 (18:44 +0200)
Fixes Ticket2840

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/jpeg2000dec.c

index 1eb20ac..3c14a13 100644 (file)
@@ -1343,13 +1343,15 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
 {
     int tileno, compno;
     for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) {
-        for (compno = 0; compno < s->ncomponents; compno++) {
-            Jpeg2000Component *comp     = s->tile[tileno].comp   + compno;
-            Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno;
+        if (s->tile[tileno].comp) {
+            for (compno = 0; compno < s->ncomponents; compno++) {
+                Jpeg2000Component *comp     = s->tile[tileno].comp   + compno;
+                Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno;
 
-            ff_jpeg2000_cleanup(comp, codsty);
+                ff_jpeg2000_cleanup(comp, codsty);
+            }
+            av_freep(&s->tile[tileno].comp);
         }
-        av_freep(&s->tile[tileno].comp);
     }
     av_freep(&s->tile);
     s->numXtiles = s->numYtiles = 0;