summaryrefslogtreecommitdiff
path: root/src/cairo-path.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-05-11 18:25:13 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-05-16 15:28:57 +0100
commit35eb65b7772459266e2f954fb370bfdca12b5b64 (patch)
tree0d20c2d9c9f33bea3aa842055842e0a26f6740bf /src/cairo-path.c
parenta60afb0e78ab42498158ef852fcea35c8f71e8ec (diff)
[cairo-path] Check for errors during the count.
Return the nil object if we encounter any error whilst trying to generate the path. Also special case the NO_MEMORY error object to return the nil object.
Diffstat (limited to 'src/cairo-path.c')
-rw-r--r--src/cairo-path.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cairo-path.c b/src/cairo-path.c
index cf2dd4d92..4c8e09e11 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -154,7 +154,7 @@ _cairo_path_count (cairo_path_t *path,
_cpc_close_path,
&cpc);
if (status)
- return 0;
+ return -1;
return cpc.count;
}
@@ -347,6 +347,10 @@ _cairo_path_create_in_error (cairo_status_t status)
{
cairo_path_t *path;
+ /* special case NO_MEMORY so as to avoid allocations */
+ if (status == CAIRO_STATUS_NO_MEMORY)
+ return (cairo_path_t*) &_cairo_path_nil;
+
path = malloc (sizeof (cairo_path_t));
if (path == NULL)
return (cairo_path_t*) &_cairo_path_nil;
@@ -372,6 +376,10 @@ _cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
path->num_data = _cairo_path_count (path, path_fixed,
_cairo_gstate_get_tolerance (gstate),
flatten);
+ if (path->num_data <= 0) {
+ free (path);
+ return (cairo_path_t*) &_cairo_path_nil;
+ }
path->data = malloc (path->num_data * sizeof (cairo_path_data_t));
if (path->data == NULL) {