]> granicus.if.org Git - imagemagick/commitdiff
Set pixel cache to undefined if any resource limit is exceeded
authorCristy <urban-warrior@imagemagick.org>
Mon, 16 May 2016 20:05:02 +0000 (16:05 -0400)
committerCristy <urban-warrior@imagemagick.org>
Mon, 16 May 2016 20:05:02 +0000 (16:05 -0400)
MagickCore/cache.c
MagickCore/image.c
coders/wpg.c

index 2f671608f65fd2e48a46d5305ed864a552ebdcdb..921ddbf27e92a604c29ba571026071b729037788 100644 (file)
@@ -3504,6 +3504,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
             }
         }
       RelinquishMagickResource(DiskResource,cache_info->length);
+      cache_info->type=UndefinedCache;
       (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
         "CacheResourcesExhausted","`%s'",image->filename);
       return(MagickFalse);
@@ -3516,6 +3517,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
   if (OpenPixelCacheOnDisk(cache_info,mode) == MagickFalse)
     {
       RelinquishMagickResource(DiskResource,cache_info->length);
+      cache_info->type=UndefinedCache;
       ThrowFileException(exception,CacheError,"UnableToOpenPixelCache",
         image->filename);
       return(MagickFalse);
@@ -3524,6 +3526,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
     cache_info->length);
   if (status == MagickFalse)
     {
+      cache_info->type=UndefinedCache;
       ThrowFileException(exception,CacheError,"UnableToExtendCache",
         image->filename);
       return(MagickFalse);
@@ -3582,6 +3585,8 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
                   (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",
                     message);
                 }
+              if (status == MagickFalse)
+                cache_info->type=UndefinedCache;
               return(status);
             }
         }
@@ -3606,6 +3611,8 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
         cache_info->number_channels,format);
       (void) LogMagickEvent(CacheEvent,GetMagickModule(),"%s",message);
     }
+  if (status == MagickFalse)
+    cache_info->type=UndefinedCache;
   return(status);
 }
 \f
index 1b3519571347de20d99e32b7697b798886623a9c..a41ad0cc60a8c82b8cb582174baf1a6bd7cbc019 100644 (file)
@@ -843,7 +843,10 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns,
       clone_image->colormap=(PixelInfo *) AcquireQuantumMemory(length,
         sizeof(*clone_image->colormap));
       if (clone_image->colormap == (PixelInfo *) NULL)
-        ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
+        {
+          clone_image=DestroyImage(clone_image);
+          ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
+        }
       (void) CopyMagickMemory(clone_image->colormap,image->colormap,length*
         sizeof(*clone_image->colormap));
     }
index 0dfdc47f0b31d6588a6a6a1477f78de32e7191ca..782f25e827f33555df98c87bcc872420f1056c2d 100644 (file)
@@ -1311,7 +1311,6 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               status=SetImageExtent(image,image->columns,image->rows,exception);
               if (status == MagickFalse)
                 break;
-
               if ((image->colors == 0) && (bpp != 24))
                 {
                   size_t