diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-06-01 00:51:30 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-03 03:22:17 +0200 |
commit | 1047c286fa20c79dde8ddd7577a3b87cc1effdb7 (patch) | |
tree | d5afc76702e06be8f5222c151e121dc258e972a5 /libavcodec/libopenjpegenc.c | |
parent | bf6ba4a0328167802236e5e4727342a0c2f225f2 (diff) | |
download | ffmpeg-1047c286fa20c79dde8ddd7577a3b87cc1effdb7.tar.gz |
libopenjpegenc: add NULL check for img before accessing itn2.4.10
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@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit 1577526b47439f33a999339efdec5d624b70e1da)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libopenjpegenc.c')
-rw-r--r-- | libavcodec/libopenjpegenc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 66633f4ad2..458cf7c2c1 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; |