[FFmpeg-devel] [PATCH] libopenjpegenc: add NULL check for img before accessing it
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Mon Jun 1 00:57:25 CEST 2015
If opj_image_create fails to allocate an image it returns NULL, which
causes a segmentation fault at 'img->x0 = 0'.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
libavcodec/libopenjpegenc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 95b0987..6c77527 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -200,6 +200,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;
--
2.1.4
More information about the ffmpeg-devel
mailing list