From cdddf99e151c9c2750af70e172d4b6dcb481e1b0 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sat, 29 Jun 2019 13:23:09 +0200 Subject: [PATCH] Fixed invalid free. --- coders/heic.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/coders/heic.c b/coders/heic.c index ed59192e8..10d60c477 100644 --- a/coders/heic.c +++ b/coders/heic.c @@ -340,6 +340,11 @@ static MagickBooleanType ReadHEICImageByID(const ImageInfo *image_info, (void) SetImageProperty(image,"exif:Orientation","1",exception); error=heif_decode_image(image_handle,&heif_image,heif_colorspace_YCbCr, heif_chroma_420,decode_options); + if (IsHeifSuccess(&error,image,exception) == MagickFalse) + { + heif_image_handle_release(image_handle); + return(MagickFalse); + } if (decode_options != (struct heif_decoding_options *) NULL) { /* @@ -349,13 +354,12 @@ static MagickBooleanType ReadHEICImageByID(const ImageInfo *image_info, image->rows=(size_t) heif_image_get_height(heif_image,heif_channel_Y); status=SetImageExtent(image,image->columns,image->rows,exception); heif_decoding_options_free(decode_options); - } - if ((IsHeifSuccess(&error,image,exception) == MagickFalse) || - (status == MagickFalse)) - { - heif_image_release(heif_image); - heif_image_handle_release(image_handle); - return(MagickFalse); + if (status == MagickFalse) + { + heif_image_release(heif_image); + heif_image_handle_release(image_handle); + return(MagickFalse); + } } p_y=heif_image_get_plane(heif_image,heif_channel_Y,&stride_y); p_cb=heif_image_get_plane(heif_image,heif_channel_Cb,&stride_cb); -- 2.40.0