libopenjpegdec: always check image because decoding may still fail
authorPaul B Mahol <onemda@gmail.com>
Mon, 26 Mar 2012 02:01:23 +0000 (02:01 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 26 Mar 2012 03:01:57 +0000 (05:01 +0200)
Fixes bunch of segfaults.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/libopenjpegdec.c

index 29724a2..fced76d 100644 (file)
@@ -295,6 +295,11 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
     // Decode the codestream
     image = opj_decode_with_info(dec, stream, NULL);
     opj_cio_close(stream);
+    if(!image) {
+        av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
+        opj_destroy_decompress(dec);
+        return -1;
+    }
 
     pixel_size = av_pix_fmt_descriptors[avctx->pix_fmt].comp[0].step_minus1 + 1;
     ispacked = libopenjpeg_ispacked(avctx->pix_fmt);