gdiplus: Avoid infinite recursion in flatten_bezier().

Ken Thomases ken at codeweavers.com
Mon Apr 24 13:16:08 CDT 2017


If either of the recursive calls would have the same x2, y2, x3, and y3
arguments as the current call, the path is as flat as the precision of floats
allows.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
 dlls/gdiplus/graphicspath.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 5a3356a..4d70796 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -142,6 +142,10 @@ static BOOL flatten_bezier(path_list_node_t *start, REAL x2, REAL y2, REAL x3, R
     mp[2].X = (mp[1].X + mp[3].X) / 2.0;
     mp[2].Y = (mp[1].Y + mp[3].Y) / 2.0;
 
+    if ((x2 == mp[0].X && y2 == mp[0].Y && x3 == mp[1].X && y3 == mp[1].Y) ||
+        (x2 == mp[3].X && y2 == mp[3].Y && x3 == mp[4].X && y3 == mp[4].Y))
+        return TRUE;
+
     pt = end->pt;
     pt_st = start->pt;
     /* check flatness as a half of distance between middle point and a linearized path */
-- 
2.10.2




More information about the wine-patches mailing list