]> granicus.if.org Git - imagemagick/commitdiff
Some refactoring.
authorDirk Lemstra <dirk@git.imagemagick.org>
Sun, 17 Sep 2017 06:48:36 +0000 (08:48 +0200)
committerDirk Lemstra <dirk@git.imagemagick.org>
Sun, 17 Sep 2017 06:48:36 +0000 (08:48 +0200)
coders/meta.c

index 482173151975dd0eea72f9c417b73a17212909d8..3e2931e7195d4e8017253257e704d6dca26e049a 100644 (file)
@@ -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))