From 66e283e0a9c141b19fe6c4c39f4a41c0d3188ba8 Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 10 Jan 2017 20:15:11 -0500 Subject: [PATCH] ... --- ChangeLog | 1 + coders/mpc.c | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21645cbf7..5923556f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2017-01-10 7.0.4-4 Cristy * Recognize XML policy closing tags (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31182). + * Fix memory leak in the MPC format. 2017-01-07 7.0.4-3 Cristy * Release ImageMagick version 7.0.4-3, GIT revision 19329:930ca78:20170107. diff --git a/coders/mpc.c b/coders/mpc.c index e6d3473c8..c011c2bcb 100644 --- a/coders/mpc.c +++ b/coders/mpc.c @@ -66,6 +66,7 @@ #include "MagickCore/profile.h" #include "MagickCore/property.h" #include "MagickCore/quantum-private.h" +#include "MagickCore/resource.h" #include "MagickCore/static.h" #include "MagickCore/statistic.h" #include "MagickCore/string_.h" @@ -834,7 +835,9 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Create image colormap. */ - if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) + image->colormap=(PixelInfo *) AcquireQuantumMemory(image->colors+1, + sizeof(*image->colormap)); + if (image->colormap == (PixelInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); if (image->colors != 0) { @@ -923,9 +926,9 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - status=SetImageExtent(image,image->columns,image->rows,exception); - if (status == MagickFalse) - return(DestroyImageList(image)); + if ((AcquireMagickResource(WidthResource,image->columns) == MagickFalse) || + (AcquireMagickResource(HeightResource,image->rows) == MagickFalse)) + ThrowReaderException(ImageError,"WidthOrHeightExceedsLimit"); /* Attach persistent pixel cache. */ -- 2.40.0