From 9c5d1aa2957c54adaa4ba1aa2af4a38e71b607d9 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 20 Oct 2014 14:51:06 +0200 Subject: [PATCH] Fix infinite recursion in agg when drawing bezier with invalid points * Patch extracted from http://trac.osgeo.org/mapserver/ticket/3862 * Fixes #6738 --- headers/libs/agg/agg_conv_curve.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/headers/libs/agg/agg_conv_curve.h b/headers/libs/agg/agg_conv_curve.h index f682a59d72..751e08d9fa 100644 --- a/headers/libs/agg/agg_conv_curve.h +++ b/headers/libs/agg/agg_conv_curve.h @@ -165,12 +165,15 @@ namespace agg case path_cmd_curve3: m_source->vertex(&end_x, &end_y); - m_curve3.init(m_last_x, m_last_y, - *x, *y, - end_x, end_y); + if (!isnan(m_last_x) && !isnan(m_last_y) && !isnan(*x) && !isnan(*y) + && !isnan(end_x) && !isnan(end_y)) { + m_curve3.init(m_last_x, m_last_y, + *x, *y, + end_x, end_y); - m_curve3.vertex(x, y); // First call returns path_cmd_move_to - m_curve3.vertex(x, y); // This is the first vertex of the curve + m_curve3.vertex(x, y); // First call returns path_cmd_move_to + m_curve3.vertex(x, y); // This is the first vertex of the curve + } cmd = path_cmd_line_to; break; @@ -178,13 +181,16 @@ namespace agg m_source->vertex(&ct2_x, &ct2_y); m_source->vertex(&end_x, &end_y); - m_curve4.init(m_last_x, m_last_y, - *x, *y, - ct2_x, ct2_y, - end_x, end_y); + if (!isnan(m_last_x) && !isnan(m_last_y) && !isnan(*x) && !isnan(*y) + && !isnan(end_x) && !isnan(end_y)) { + m_curve4.init(m_last_x, m_last_y, + *x, *y, + ct2_x, ct2_y, + end_x, end_y); - m_curve4.vertex(x, y); // First call returns path_cmd_move_to - m_curve4.vertex(x, y); // This is the first vertex of the curve + m_curve4.vertex(x, y); // First call returns path_cmd_move_to + m_curve4.vertex(x, y); // This is the first vertex of the curve + } cmd = path_cmd_line_to; break; }