From 98d7071d0ce8e7af88d8f16585fbccaa381489c6 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 17 Sep 2017 08:48:36 +0200 Subject: [PATCH] Some refactoring. --- coders/meta.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/coders/meta.c b/coders/meta.c index 482173151..3e2931e71 100644 --- a/coders/meta.c +++ b/coders/meta.c @@ -1228,22 +1228,17 @@ static Image *ReadMETAImage(const ImageInfo *image_info, if (profile == (StringInfo *) NULL) { blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); + blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } status=SetImageProfile(image,"8bim",profile,exception); profile=DestroyStringInfo(profile); - if (status == MagickFalse) - { - blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); - buff=DestroyImage(buff); - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - } blob=DetachBlob(buff->blob); blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } if (LocaleNCompare(image_info->magick,"APP1",4) == 0) { @@ -1272,7 +1267,7 @@ static Image *ReadMETAImage(const ImageInfo *image_info, if (image_info->profile == (void *) NULL) { blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); + blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(CoderError,"NoIPTCProfileAvailable"); } @@ -1281,7 +1276,7 @@ static Image *ReadMETAImage(const ImageInfo *image_info, if (iptc == (Image *) NULL) { blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); + blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } @@ -1289,12 +1284,10 @@ static Image *ReadMETAImage(const ImageInfo *image_info, GetStringInfoLength(profile)); result=jpeg_embed(image,buff,iptc); blob=DetachBlob(iptc->blob); - blob=RelinquishMagickMemory(blob); + blob=(unsigned char *) RelinquishMagickMemory(blob); iptc=DestroyImage(iptc); if (result == 0) { - blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(CoderError,"JPEGEmbeddingFailed"); } @@ -1306,22 +1299,17 @@ static Image *ReadMETAImage(const ImageInfo *image_info, if (profile == (StringInfo *) NULL) { blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); + blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } status=SetImageProfile(image,name,profile,exception); profile=DestroyStringInfo(profile); - if (status == MagickFalse) - { - blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); - buff=DestroyImage(buff); - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - } blob=DetachBlob(buff->blob); - blob=RelinquishMagickMemory(blob); + blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } if ((LocaleCompare(image_info->magick,"ICC") == 0) || (LocaleCompare(image_info->magick,"ICM") == 0)) -- 2.40.0