Browse Source

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@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit 1577526b47)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tags/n2.4.10^0
Andreas Cadhalpun Michael Niedermayer 10 years ago
parent
commit
1047c286fa
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      libavcodec/libopenjpegenc.c

+ 3
- 0
libavcodec/libopenjpegenc.c View File

@@ -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;


Loading…
Cancel
Save