From ebcfe7408de48710782ef659a2a5313692388514 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 8 Apr 2009 15:12:39 +0200 Subject: Warn when closing an empty path instead of aborting. --- fitz/node_path.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fitz/node_path.c b/fitz/node_path.c index f10fd982..c21de87a 100644 --- a/fitz/node_path.c +++ b/fitz/node_path.c @@ -95,6 +95,8 @@ fz_moveto(fz_pathnode *path, float x, float y) fz_error fz_lineto(fz_pathnode *path, float x, float y) { + if (path->len == 0) + return fz_throw("no current point"); if (growpath(path, 3) != fz_okay) return fz_rethrow(-1, "out of memory"); path->els[path->len++].k = FZ_LINETO; @@ -109,6 +111,8 @@ fz_curveto(fz_pathnode *path, float x2, float y2, float x3, float y3) { + if (path->len == 0) + return fz_throw("no current point"); if (growpath(path, 7) != fz_okay) return fz_rethrow(-1, "out of memory"); path->els[path->len++].k = FZ_CURVETO; @@ -138,6 +142,12 @@ fz_curvetoy(fz_pathnode *path, float x1, float y1, float x3, float y3) fz_error fz_closepath(fz_pathnode *path) { + if (path->len == 0) + { + fz_warn("tried to close an empty path"); + return fz_okay; + } + if (growpath(path, 1) != fz_okay) return fz_rethrow(-1, "out of memory"); path->els[path->len++].k = FZ_CLOSEPATH; -- cgit v1.2.3