From 88a140b6bd8691b9ebfcf147f3a275ad2069bf8b Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 3 Sep 2018 08:18:28 -0400 Subject: [PATCH] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10202 --- MagickCore/draw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MagickCore/draw.c b/MagickCore/draw.c index da190b018..4ff763cc8 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -2244,7 +2244,7 @@ static MagickBooleanType CheckPrimitiveExtent(MVGInfo *mvg_info, if (~extent >= pad) { extent+=4096; - if (~extent >= 4096) + if ((~extent >= 4096) && (extent <= GetMaxMemoryRequest())) { if (extent <= *mvg_info->extent) return(MagickTrue); @@ -2263,6 +2263,9 @@ static MagickBooleanType CheckPrimitiveExtent(MVGInfo *mvg_info, */ (void) ThrowMagickException(mvg_info->exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",""); + if (*mvg_info->primitive_info != (PrimitiveInfo *) NULL) + *mvg_info->primitive_info=(PrimitiveInfo *) + RelinquishMagickMemory(*mvg_info->primitive_info); *mvg_info->primitive_info=AcquireCriticalMemory(4* sizeof(**mvg_info->primitive_info)); (void) memset(*mvg_info->primitive_info,0,sizeof(**mvg_info->primitive_info)); -- 2.40.0