From f3c1ca2e0ead82cfab305859cdd7b34c82daa655 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 23 Jun 2019 13:51:10 -0400 Subject: [PATCH] geMagick/ImageMagick6/issues/46 --- MagickCore/cache.c | 12 +++++++++++- MagickCore/layer.c | 48 +++++++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index e3400efbe..e0863a0b5 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -434,6 +434,8 @@ static MagickBooleanType ClipPixelCacheNexus(Image *image, (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if ((image->channels & WriteMaskChannel) == 0) return(MagickTrue); + if ((nexus_info->region.width == 0) || (nexus_info->region.height == 0)) + return(MagickTrue); cache_info=(CacheInfo *) image->cache; if (cache_info == (Cache) NULL) return(MagickFalse); @@ -3406,6 +3408,8 @@ static MagickBooleanType MaskPixelCacheNexus(Image *image,NexusInfo *nexus_info, (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if ((image->channels & CompositeMaskChannel) == 0) return(MagickTrue); + if ((nexus_info->region.width == 0) || (nexus_info->region.height == 0)) + return(MagickTrue); cache_info=(CacheInfo *) image->cache; if (cache_info == (Cache) NULL) return(MagickFalse); @@ -5018,8 +5022,14 @@ static Quantum *SetPixelCacheNexusPixels( assert(cache_info->signature == MagickCoreSignature); if (cache_info->type == UndefinedCache) return((Quantum *) NULL); - (void) memset(&nexus_info->region,0,sizeof(nexus_info->region)); assert(nexus_info->signature == MagickCoreSignature); + (void) memset(&nexus_info->region,0,sizeof(nexus_info->region)); + if ((width == 0) || (height == 0)) + { + (void) ThrowMagickException(exception,GetMagickModule(),CacheError, + "NoPixelsDefinedInCache","`%s'",cache_info->filename); + return((Quantum *) NULL); + } if (((cache_info->type == MemoryCache) || (cache_info->type == MapCache)) && (buffered == MagickFalse)) { diff --git a/MagickCore/layer.c b/MagickCore/layer.c index 279689df6..b520e9247 100644 --- a/MagickCore/layer.c +++ b/MagickCore/layer.c @@ -574,7 +574,7 @@ static MagickBooleanType ComparePixels(const LayerMethod method, % The format of the CompareImagesBounds method is: % % RectangleInfo *CompareImagesBounds(const LayerMethod method, -% const Image *image1, const Image *image2, ExceptionInfo *exception) +% const Image *image1,const Image *image2,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -741,7 +741,7 @@ static RectangleInfo CompareImagesBounds(const Image *image1, */ MagickExport Image *CompareImagesLayers(const Image *image, - const LayerMethod method, ExceptionInfo *exception) + const LayerMethod method,ExceptionInfo *exception) { Image *image_a, @@ -881,7 +881,7 @@ MagickExport Image *CompareImagesLayers(const Image *image, % The format of the OptimizeLayerFrames method is: % % Image *OptimizeLayerFrames(const Image *image, -% const LayerMethod method, ExceptionInfo *exception) +% const LayerMethod method,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -909,8 +909,8 @@ MagickExport Image *CompareImagesLayers(const Image *image, #define DEBUG_OPT_FRAME 0 -static Image *OptimizeLayerFrames(const Image *image, - const LayerMethod method, ExceptionInfo *exception) +static Image *OptimizeLayerFrames(const Image *image,const LayerMethod method, + ExceptionInfo *exception) { ExceptionInfo *sans_exception; @@ -1008,7 +1008,7 @@ static Image *OptimizeLayerFrames(const Image *image, */ #if DEBUG_OPT_FRAME i=0; - (void) FormatLocaleFile(stderr, "frame %.20g :-\n", (double) i); + (void) FormatLocaleFile(stderr,"frame %.20g :-\n",(double) i); #endif disposals[0]=NoneDispose; bounds[0]=CompareImagesBounds(prev_image,curr,CompareAnyLayer,exception); @@ -1031,7 +1031,7 @@ static Image *OptimizeLayerFrames(const Image *image, for ( ; curr != (const Image *) NULL; curr=GetNextImageInList(curr)) { #if DEBUG_OPT_FRAME - (void) FormatLocaleFile(stderr, "frame %.20g :-\n", (double) i); + (void) FormatLocaleFile(stderr,"frame %.20g :-\n",(double) i); #endif /* Assume none disposal is the best @@ -1082,9 +1082,9 @@ static Image *OptimizeLayerFrames(const Image *image, bounds[i]=try_bounds; disposals[i-1]=PreviousDispose; #if DEBUG_OPT_FRAME - (void) FormatLocaleFile(stderr, "previous: accepted\n"); + (void) FormatLocaleFile(stderr,"previous: accepted\n"); } else { - (void) FormatLocaleFile(stderr, "previous: rejected\n"); + (void) FormatLocaleFile(stderr,"previous: rejected\n"); #endif } @@ -1244,9 +1244,9 @@ static Image *OptimizeLayerFrames(const Image *image, dup_image=DestroyImage(dup_image); disposals[i-1]=BackgroundDispose; #if DEBUG_OPT_FRAME - (void) FormatLocaleFile(stderr, "expand_bgnd: accepted\n"); + (void) FormatLocaleFile(stderr,"expand_bgnd: accepted\n"); } else { - (void) FormatLocaleFile(stderr, "expand_bgnd: reject\n"); + (void) FormatLocaleFile(stderr,"expand_bgnd: reject\n"); #endif } } @@ -1273,7 +1273,7 @@ static Image *OptimizeLayerFrames(const Image *image, if ( disposals[i-1] != PreviousDispose ) prev_image=DestroyImage(prev_image); if ( disposals[i-1] == BackgroundDispose ) - prev_image=bgnd_image, bgnd_image=(Image *) NULL; + prev_image=bgnd_image, bgnd_image=(Image *) NULL; if (bgnd_image != (Image *) NULL) bgnd_image=DestroyImage(bgnd_image); if ( disposals[i-1] == NoneDispose ) @@ -1293,17 +1293,17 @@ static Image *OptimizeLayerFrames(const Image *image, #if DEBUG_OPT_FRAME (void) FormatLocaleFile(stderr, "final %.20g : %s %.20gx%.20g%+.20g%+.20g\n", (double) i-1, - CommandOptionToMnemonic(MagickDisposeOptions, disposals[i-1]), - (double) bounds[i-1].width, (double) bounds[i-1].height, - (double) bounds[i-1].x, (double) bounds[i-1].y ); + CommandOptionToMnemonic(MagickDisposeOptions,disposals[i-1]), + (double) bounds[i-1].width,(double) bounds[i-1].height, + (double) bounds[i-1].x,(double) bounds[i-1].y ); #endif #if DEBUG_OPT_FRAME (void) FormatLocaleFile(stderr, "interum %.20g : %s %.20gx%.20g%+.20g%+.20g\n", (double) i, - CommandOptionToMnemonic(MagickDisposeOptions, disposals[i]), - (double) bounds[i].width, (double) bounds[i].height, - (double) bounds[i].x, (double) bounds[i].y ); - (void) FormatLocaleFile(stderr, "\n"); + CommandOptionToMnemonic(MagickDisposeOptions,disposals[i]), + (double) bounds[i].width,(double) bounds[i].height, + (double) bounds[i].x,(double) bounds[i].y ); + (void) FormatLocaleFile(stderr,"\n"); #endif i++; } @@ -1422,7 +1422,7 @@ MagickExport Image *OptimizeImageLayers(const Image *image, MagickExport Image *OptimizePlusImageLayers(const Image *image, ExceptionInfo *exception) { - return OptimizeLayerFrames(image, OptimizePlusLayer, exception); + return OptimizeLayerFrames(image,OptimizePlusLayer,exception); } /* @@ -1530,7 +1530,7 @@ MagickExport void OptimizeImageTransparency(const Image *image, } if ((ssize_t) (bounds.y+bounds.height) > (ssize_t) current_image->rows) bounds.height=current_image->rows-bounds.y; - ClearBounds(current_image, &bounds,exception); + ClearBounds(current_image,&bounds,exception); } if (next->dispose != PreviousDispose) { @@ -1575,7 +1575,7 @@ MagickExport void OptimizeImageTransparency(const Image *image, % % The format of the RemoveDuplicateLayers method is: % -% void RemoveDuplicateLayers(Image **image, ExceptionInfo *exception) +% void RemoveDuplicateLayers(Image **image,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1656,7 +1656,7 @@ MagickExport void RemoveDuplicateLayers(Image **images, % % The format of the RemoveZeroDelayLayers method is: % -% void RemoveZeroDelayLayers(Image **image, ExceptionInfo *exception) +% void RemoveZeroDelayLayers(Image **image,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1782,7 +1782,7 @@ MagickExport void CompositeLayers(Image *destination, assert(exception->signature == MagickCoreSignature); if (source->debug != MagickFalse || destination->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s - %s", - source->filename, destination->filename); + source->filename,destination->filename); /* Overlay single source image over destation image/list -- 2.40.0