@@ -600,6 +600,12 @@ RendererAgg::draw_markers(const Py::Tuple& args) {
600600 agg::serialized_scanlines_adaptor_aa8 sa;
601601 agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl;
602602
603+ agg::rect_d clipping_rect (
604+ -(scanlines.min_x () + 1.0 ),
605+ -(scanlines.min_y () + 1.0 ),
606+ width + scanlines.max_x () + 1.0 ,
607+ height + scanlines.max_y () + 1.0 );
608+
603609 if (has_clippath) {
604610 while (path_curve.vertex (&x, &y) != agg::path_cmd_stop) {
605611 if (MPL_notisfinite64 (x) || MPL_notisfinite64 (y)) {
@@ -608,13 +614,13 @@ RendererAgg::draw_markers(const Py::Tuple& args) {
608614
609615 x = (double )(int )x; y = (double )(int )y;
610616
611- // if x or y is close to the width or height, the filled
612- // region could be inside the boundary even if the center is
613- // out. But at some point we need to cull these points
617+ // Cull points outside the boundary of the image. Values
618+ // that are too large may overflow and create segfaults.
614619 // because they can create segfaults of they overflow; eg
615- // https://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720
616- if (fabs (x)>(2 *width)) continue ;
617- if (fabs (y)>(2 *height)) continue ;
620+ // http://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720
621+ if (!clipping_rect.hit_test (x, y)) {
622+ continue ;
623+ }
618624
619625 pixfmt_amask_type pfa (pixFmt, alphaMask);
620626 amask_ren_type r (pfa);
@@ -637,13 +643,13 @@ RendererAgg::draw_markers(const Py::Tuple& args) {
637643
638644 x = (double )(int )x; y = (double )(int )y;
639645
640- // if x or y is close to the width or height, the filled
641- // region could be inside the boundary even if the center is
642- // out. But at some point we need to cull these points
646+ // Cull points outside the boundary of the image. Values
647+ // that are too large may overflow and create segfaults.
643648 // because they can create segfaults of they overflow; eg
644- // https://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720
645- if (fabs (x)>(2 *width)) continue ;
646- if (fabs (y)>(2 *height)) continue ;
649+ // http://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720
650+ if (!clipping_rect.hit_test (x, y)) {
651+ continue ;
652+ }
647653
648654 if (face.first ) {
649655 rendererAA.color (face.second );
0 commit comments