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

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sat May 30 16:39:03 CEST 2015


libopenjpeg can return images with components without data.

This fixes segmentation faults.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 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);
-- 
2.1.4


More information about the ffmpeg-devel mailing list