[FFmpeg-cvslog] libopenjpegdec: check existence of image component data

Andreas Cadhalpun git at videolan.org
Sat May 30 20:59:33 CEST 2015


ffmpeg | branch: master | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Sat May 30 16:18:48 2015 +0200| [3ef5702926c495232ffe685303ba8661bdff1149] | committer: Andreas Cadhalpun

libopenjpegdec: check existence of image component data

libopenjpeg can return images with components without data.

This fixes segmentation faults.

Reviewed-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ef5702926c495232ffe685303ba8661bdff1149
---

 libavcodec/libopenjpegdec.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 1cd1b9b..ab681f1 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -358,6 +358,15 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
         goto done;
     }
 
+    for (i = 0; i < image->numcomps; i++) {
+        if (!image->comps[i].data) {
+            av_log(avctx, AV_LOG_ERROR,
+                   "Image component %d contains no data.\n", i);
+            ret = AVERROR_INVALIDDATA;
+            goto done;
+        }
+    }
+
     desc       = av_pix_fmt_desc_get(avctx->pix_fmt);
     pixel_size = desc->comp[0].step_minus1 + 1;
     ispacked   = libopenjpeg_ispacked(avctx->pix_fmt);



More information about the ffmpeg-cvslog mailing list