From 943c28d70cafc2ca929a939d72afa0db195f77b2 Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 2 Oct 2018 19:36:36 -0400 Subject: [PATCH] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10776 --- MagickCore/draw.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 58190521e..f203362ba 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -1589,17 +1589,25 @@ static Image *DrawClippingMask(Image *image,const DrawInfo *draw_info, clone_info->clip_path=MagickTrue; status=RenderMVGContent(clip_mask,clone_info,1,exception); clone_info=DestroyDrawInfo(clone_info); - separate_mask=SeparateImage(clip_mask,AlphaChannel,exception); - if (separate_mask != (Image *) NULL) + if (status != MagickFalse) { - clip_mask=DestroyImage(clip_mask); - clip_mask=separate_mask; - status=NegateImage(clip_mask,MagickFalse,exception); - if (status == MagickFalse) - clip_mask=DestroyImage(clip_mask); + status=SetImageMask(clip_mask,CompositePixelMask,(Image *) NULL, + exception); + if (status != MagickFalse) + { + separate_mask=SeparateImage(clip_mask,AlphaChannel,exception); + if (separate_mask != (Image *) NULL) + { + clip_mask=DestroyImage(clip_mask); + clip_mask=separate_mask; + status=NegateImage(clip_mask,MagickFalse,exception); + } + } } if (image->debug != MagickFalse) (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path"); + if (status == MagickFalse) + clip_mask=DestroyImage(clip_mask); return(clip_mask); } @@ -1679,17 +1687,25 @@ static Image *DrawCompositeMask(Image *image,const DrawInfo *draw_info, clone_info->alpha=OpaqueAlpha; status=RenderMVGContent(composite_mask,clone_info,1,exception); clone_info=DestroyDrawInfo(clone_info); - separate_mask=SeparateImage(composite_mask,AlphaChannel,exception); - if (separate_mask != (Image *) NULL) + if (status != MagickFalse) { - composite_mask=DestroyImage(composite_mask); - composite_mask=separate_mask; - status=NegateImage(composite_mask,MagickFalse,exception); - if (status == MagickFalse) - composite_mask=DestroyImage(composite_mask); + status=SetImageMask(composite_mask,CompositePixelMask,(Image *) NULL, + exception); + if (status != MagickFalse) + { + separate_mask=SeparateImage(composite_mask,AlphaChannel,exception); + if (separate_mask != (Image *) NULL) + { + composite_mask=DestroyImage(composite_mask); + composite_mask=separate_mask; + status=NegateImage(composite_mask,MagickFalse,exception); + } + } } if (image->debug != MagickFalse) (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end mask-path"); + if (status == MagickFalse) + composite_mask=DestroyImage(composite_mask); return(composite_mask); } -- 2.40.0