j2k & jpeg2000dec: reset numX/Ytiles if tiles failed allocation
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 22 May 2013 01:17:35 +0000 (03:17 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 22 May 2013 01:18:55 +0000 (03:18 +0200)
Fixes null pointer dereference

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/j2kdec.c
libavcodec/jpeg2000dec.c

index 22bbb2e..a02b84b 100644 (file)
@@ -957,6 +957,8 @@ static int decode_codestream(Jpeg2000DecoderContext *s)
         switch (marker){
         case JPEG2000_SIZ:
             ret = get_siz(s);
+            if (!s->tile)
+                s->numXtiles = s->numYtiles = 0;
             break;
         case JPEG2000_COC:
             ret = get_coc(s, codsty, properties);
index a43cc7e..0735da1 100644 (file)
@@ -1181,6 +1181,8 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
         switch (marker) {
         case JPEG2000_SIZ:
             ret = get_siz(s);
+            if (!s->tile)
+                s->numXtiles = s->numYtiles = 0;
             break;
         case JPEG2000_COC:
             ret = get_coc(s, codsty, properties);