Skip to content

Commit

Permalink
Fixed memory leak when it failed to apply ICC color profile
Browse files Browse the repository at this point in the history
  • Loading branch information
diego.choi authored and dlemstra committed Jun 8, 2021
1 parent cde1733 commit 1d4b8f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions magick/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1d4b8f4

Please sign in to comment.