From a5d49d1c5b4762dd7aa124e6dc9de84975909e92 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 15 May 2017 20:25:38 -0400 Subject: [PATCH] ... --- MagickCore/image.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/MagickCore/image.c b/MagickCore/image.c index c2e666f51..88adbecd0 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -842,23 +842,6 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns, clone_image->columns=image->columns; clone_image->rows=image->rows; clone_image->dither=image->dither; - if (image->colormap != (PixelInfo *) NULL) - { - /* - Allocate and copy the image colormap. - */ - clone_image->colors=image->colors; - length=(size_t) image->colors; - clone_image->colormap=(PixelInfo *) AcquireQuantumMemory(length+1, - sizeof(*clone_image->colormap)); - if (clone_image->colormap == (PixelInfo *) NULL) - { - image=(Image *) RelinquishMagickMemory(image); - ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); - } - (void) CopyMagickMemory(clone_image->colormap,image->colormap,length* - sizeof(*clone_image->colormap)); - } clone_image->image_info=CloneImageInfo(image->image_info); (void) CloneImageProfiles(clone_image,image); (void) CloneImageProperties(clone_image,image); @@ -893,6 +876,23 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns, clone_image->ping=image->ping; clone_image->debug=IsEventLogging(); clone_image->semaphore=AcquireSemaphoreInfo(); + if (image->colormap != (PixelInfo *) NULL) + { + /* + Allocate and copy the image colormap. + */ + clone_image->colors=image->colors; + length=(size_t) image->colors; + clone_image->colormap=(PixelInfo *) AcquireQuantumMemory(length+1, + sizeof(*clone_image->colormap)); + if (clone_image->colormap == (PixelInfo *) NULL) + { + clone_image=DestroyImage(clone_image); + ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); + } + (void) CopyMagickMemory(clone_image->colormap,image->colormap,length* + sizeof(*clone_image->colormap)); + } if ((columns == 0) || (rows == 0)) { if (image->montage != (char *) NULL) -- 2.40.0