Skip to content

Commit b14dc55

Browse files
author
Cristy
committed
sanity check for affine when drawing
1 parent af4b9ed commit b14dc55

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

magick/draw.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,13 +1328,6 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
13281328
%
13291329
*/
13301330

1331-
static inline double SaneStrokeWidth(const Image *image,
1332-
const DrawInfo *draw_info)
1333-
{
1334-
return(MagickMin((double) draw_info->stroke_width,
1335-
(2.0*sqrt(2.0)+MagickEpsilon)*MagickMax(image->columns,image->rows)));
1336-
}
1337-
13381331
static MagickBooleanType DrawBoundingRectangles(Image *image,
13391332
const DrawInfo *draw_info,const PolygonInfo *polygon_info)
13401333
{
@@ -1389,7 +1382,7 @@ static MagickBooleanType DrawBoundingRectangles(Image *image,
13891382
resolution.y=resolution.x;
13901383
}
13911384
mid=(resolution.x/96.0)*ExpandAffine(&clone_info->affine)*
1392-
SaneStrokeWidth(image,clone_info)/2.0;
1385+
clone_info->stroke_width/2.0;
13931386
bounds.x1=0.0;
13941387
bounds.y1=0.0;
13951388
bounds.x2=0.0;
@@ -4367,6 +4360,12 @@ static MagickBooleanType RenderMVGContent(Image *image,
43674360
status&=DrawClipPath(image,graphic_context[n],
43684361
graphic_context[n]->clip_mask);
43694362
}
4363+
/*
4364+
One last sanity check before we draw.
4365+
*/
4366+
status&=CheckPrimitiveExtent(&mvg_info,
4367+
ExpandAffine(&graphic_context[n]->affine));
4368+
status&=CheckPrimitiveExtent(&mvg_info,draw_info->stroke_width);
43704369
status&=DrawPrimitive(image,graphic_context[n],primitive_info);
43714370
}
43724371
proceed=SetImageProgress(image,RenderImageTag,q-primitive,(MagickSizeType)
@@ -4807,7 +4806,7 @@ RestoreMSCWarning
48074806
(void) LogMagickEvent(DrawEvent,GetMagickModule()," begin draw-polygon");
48084807
fill=(primitive_info->method == FillToBorderMethod) ||
48094808
(primitive_info->method == FloodfillMethod) ? MagickTrue : MagickFalse;
4810-
mid=ExpandAffine(&draw_info->affine)*SaneStrokeWidth(image,draw_info)/2.0;
4809+
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
48114810
bounds=polygon_info[0]->edges[0].bounds;
48124811
for (i=1; i < (ssize_t) polygon_info[0]->number_edges; i++)
48134812
{
@@ -5514,7 +5513,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
55145513
status&=DrawDashPolygon(draw_info,primitive_info,image);
55155514
break;
55165515
}
5517-
mid=ExpandAffine(&draw_info->affine)*SaneStrokeWidth(image,draw_info)/2.0;
5516+
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
55185517
if ((mid > 1.0) &&
55195518
((draw_info->stroke.opacity != (Quantum) TransparentOpacity) ||
55205519
(draw_info->stroke_pattern != (Image *) NULL)))
@@ -7184,7 +7183,7 @@ static PrimitiveInfo *TraceStrokePolygon(const Image *image,
71847183
slope.p=dy.p/dx.p;
71857184
inverse_slope.p=(-1.0/slope.p);
71867185
}
7187-
mid=ExpandAffine(&draw_info->affine)*SaneStrokeWidth(image,draw_info)/2.0;
7186+
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
71887187
miterlimit=(double) (draw_info->miterlimit*draw_info->miterlimit*mid*mid);
71897188
if ((draw_info->linecap == SquareCap) && (closed_path == MagickFalse))
71907189
(void) TraceSquareLinecap(polygon_primitive,number_vertices,mid);

0 commit comments

Comments
 (0)