summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-10-04 09:08:46 +0100
committerCarl Worth <cworth@cworth.org>2007-11-26 21:24:47 -0800
commit886bd8ee9b594478522ebf315f5bc809d837509f (patch)
treee1f23de45293a9b04c7841bcec2c61732dc04d20
parent3454ef0984299d19e79ceb705a84c4a706704e29 (diff)
[cairo-path] Check for an empty path in cairo_append_path().
As we now generate empty paths, we must be able to handle empty paths in the user facing API. cairo_append_path() has an explicit check, and raises an error, for a NULL path->data, so we need to check the path->num_data first for empty paths. (cherry picked from commit ef5f460eb1f86a73e016c1150723ae1e70b3b037)
-rw-r--r--src/cairo.c3
-rw-r--r--test/copy-path.c15
2 files changed, 18 insertions, 0 deletions
diff --git a/src/cairo.c b/src/cairo.c
index 6859e45b..c6ea8c59 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -3405,6 +3405,9 @@ cairo_append_path (cairo_t *cr,
return;
}
+ if (path->num_data == 0)
+ return;
+
if (path->data == NULL) {
_cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);
return;
diff --git a/test/copy-path.c b/test/copy-path.c
index 256f4612..362bb34d 100644
--- a/test/copy-path.c
+++ b/test/copy-path.c
@@ -141,7 +141,13 @@ draw (cairo_t *cr, int width, int height)
cairo_path_destroy (path);
return CAIRO_TEST_FAILURE;
}
+ cairo_append_path (cr, path);
cairo_path_destroy (path);
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ cairo_test_log ("Error: cairo_append_path failed with a copy of an empty path, returned status of %s\n",
+ cairo_status_to_string (cairo_status (cr)));
+ return CAIRO_TEST_FAILURE;
+ }
/* We draw in the default black, so paint white first. */
cairo_save (cr);
@@ -224,6 +230,15 @@ main (void)
path.num_data = 0;
path.status = CAIRO_STATUS_SUCCESS;
cairo_append_path (cr, &path);
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+ return 1;
+ cairo_destroy (cr);
+
+ cr = cairo_create (surface);
+ path.data = NULL;
+ path.num_data = 1;
+ path.status = CAIRO_STATUS_SUCCESS;
+ cairo_append_path (cr, &path);
if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER)
return 1;
cairo_destroy (cr);