Skip to content
Permalink
Browse files Browse the repository at this point in the history
Set pixel cache to undefined if any resource limit is exceeded
  • Loading branch information
Cristy committed May 16, 2016
1 parent a672d4c commit aecd0ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions MagickCore/cache.c
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion MagickCore/image.c
Expand Up @@ -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));
}
Expand Down
1 change: 0 additions & 1 deletion coders/wpg.c
Expand Up @@ -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
Expand Down

0 comments on commit aecd0ad

Please sign in to comment.