From: Dirk Lemstra Date: Thu, 5 Apr 2018 20:25:19 +0000 (+0200) Subject: Moved SetImageExtent and fixed memory leak when this returns false. X-Git-Tag: 7.0.7-29~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa2dc81f30479e4a57958b36248720404ae83b72;p=imagemagick Moved SetImageExtent and fixed memory leak when this returns false. --- diff --git a/coders/jp2.c b/coders/jp2.c index a793e1f6c..b0fe16508 100644 --- a/coders/jp2.c +++ b/coders/jp2.c @@ -399,9 +399,6 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) image->columns=(size_t) jp2_image->comps[0].w; image->rows=(size_t) jp2_image->comps[0].h; image->depth=jp2_image->comps[0].prec; - status=SetImageExtent(image,image->columns,image->rows,exception); - if (status == MagickFalse) - return(DestroyImageList(image)); image->compression=JPEG2000Compression; if (jp2_image->numcomps == 1) SetImageColorspace(image,GRAYColorspace,exception); @@ -436,6 +433,13 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) opj_image_destroy(jp2_image); return(GetFirstImageInList(image)); } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + { + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + return(DestroyImageList(image)); + } for (y=0; y < (ssize_t) image->rows; y++) { register Quantum