From 5600da43ce1faef4853dff1fe336e757f5307ce6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 9 Aug 2011 16:31:43 +0200 Subject: Fix bug 692253: handle curvetov with no current point set. Also ignore path components with no current point set and print a warning rather than doing an implicit moveto(0,0). --- fitz/res_path.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'fitz/res_path.c') diff --git a/fitz/res_path.c b/fitz/res_path.c index b9eb1ee3..328e5ac1 100644 --- a/fitz/res_path.c +++ b/fitz/res_path.c @@ -57,7 +57,10 @@ void fz_lineto(fz_path *path, float x, float y) { if (path->len == 0) - fz_moveto(path, 0, 0); + { + fz_warn("lineto with no current point"); + return; + } grow_path(path, 3); path->items[path->len++].k = FZ_LINETO; path->items[path->len++].v = x; @@ -71,7 +74,10 @@ fz_curveto(fz_path *path, float x3, float y3) { if (path->len == 0) - fz_moveto(path, 0, 0); + { + fz_warn("curveto with no current point"); + return; + } grow_path(path, 7); path->items[path->len++].k = FZ_CURVETO; path->items[path->len++].v = x1; @@ -85,8 +91,14 @@ fz_curveto(fz_path *path, void fz_curvetov(fz_path *path, float x2, float y2, float x3, float y3) { - float x1 = path->items[path->len-2].v; - float y1 = path->items[path->len-1].v; + float x1, y1; + if (path->len == 0) + { + fz_warn("curvetov with no current point"); + return; + } + x1 = path->items[path->len-2].v; + y1 = path->items[path->len-1].v; fz_curveto(path, x1, y1, x2, y2, x3, y3); } @@ -100,7 +112,10 @@ void fz_closepath(fz_path *path) { if (path->len == 0) + { + fz_warn("closepath with no current point"); return; + } grow_path(path, 1); path->items[path->len++].k = FZ_CLOSE_PATH; } -- cgit v1.2.3