[FFmpeg-cvslog] libopenjpegenc: add NULL check for img before accessing it

Andreas Cadhalpun git at videolan.org
Wed Jun 17 22:09:32 CEST 2015


ffmpeg | branch: release/2.2 | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Mon Jun  1 00:51:30 2015 +0200| [b71657324d0c50a4a3fb0cca9fde2403a295a50c] | committer: Michael Niedermayer

libopenjpegenc: add NULL check for img before accessing it

If opj_image_create fails to allocate an image it returns NULL, which
causes a segmentation fault at 'img->x0 = 0'.

Reviewed-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
(cherry picked from commit 1577526b47439f33a999339efdec5d624b70e1da)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/libopenjpegenc.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 083da64..c94a112 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -164,6 +164,9 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
 
     img = opj_image_create(numcomps, cmptparm, color_space);
 
+    if (!img)
+        return NULL;
+
     // x0, y0 is the top left corner of the image
     // x1, y1 is the width, height of the reference grid
     img->x0 = 0;



More information about the ffmpeg-cvslog mailing list