From f02ffadbaecb94b7bb272a983f29a14e6e026bab Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 30 Sep 2017 11:06:13 -0400 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/819 --- MagickCore/montage.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MagickCore/montage.c b/MagickCore/montage.c index be2166905..7b64e667c 100644 --- a/MagickCore/montage.c +++ b/MagickCore/montage.c @@ -638,7 +638,14 @@ MagickExport Image *MontageImageList(const ImageInfo *image_info, sizeof(*montage->directory)); if ((montage->montage == (char *) NULL) || (montage->directory == (char *) NULL)) - ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); + { + if (montage->montage != (char *) NULL) + montage->montage=(char *) RelinquishMagickMemory(montage->montage); + if (montage->directory != (char *) NULL) + montage->directory=(char *) RelinquishMagickMemory( + montage->directory); + ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); + } x_offset=0; y_offset=0; if (montage_info->tile != (char *) NULL) -- 2.40.0