Permalink
Browse files

Set pixel cache to undefined if any resource limit is exceeded

  • Loading branch information...
Cristy
Cristy committed May 16, 2016
1 parent a672d4c commit aecd0ada163a4d6c769cec178955d5f3e9316f2f
Showing with 11 additions and 2 deletions.
  1. +7 −0 MagickCore/cache.c
  2. +4 −1 MagickCore/image.c
  3. +0 −1 coders/wpg.c
View
@@ -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);
}
View
@@ -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));
}
View
@@ -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

0 comments on commit aecd0ad

Please sign in to comment.