From 1d4b8f499985f5b576b53b7b478a9c5ab82116d1 Mon Sep 17 00:00:00 2001 From: "diego.choi" Date: Mon, 7 Jun 2021 19:06:02 +0900 Subject: [PATCH] Fixed memory leak when it failed to apply ICC color profile --- magick/profile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/magick/profile.c b/magick/profile.c index 0d235137f7..d61555134f 100644 --- a/magick/profile.c +++ b/magick/profile.c @@ -885,14 +885,18 @@ MagickExport MagickBooleanType ProfileImage(Image *image,const char *name, */ cms_context=cmsCreateContext(NULL,image); if (cms_context == (cmsContext) NULL) - ThrowBinaryImageException(ResourceLimitError, - "ColorspaceColorProfileMismatch",name); + { + profile=DestroyStringInfo(profile); + ThrowBinaryImageException(ResourceLimitError, + "ColorspaceColorProfileMismatch",name); + } cmsSetLogErrorHandlerTHR(cms_context,LCMSExceptionHandler); source_info.profile=cmsOpenProfileFromMemTHR(cms_context, GetStringInfoDatum(profile),(cmsUInt32Number) GetStringInfoLength(profile)); if (source_info.profile == (cmsHPROFILE) NULL) { + profile=DestroyStringInfo(profile); cmsDeleteContext(cms_context); ThrowBinaryImageException(ResourceLimitError, "ColorspaceColorProfileMismatch",name);