summaryrefslogtreecommitdiff
path: root/src/test-paginated-surface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-10-05 00:57:38 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-10-05 16:16:36 +0100
commitd2557cd5eec7e51496d6b1b57899b2a028898a7c (patch)
tree7725a6d531f340fe66293e3c4614126ce0021226 /src/test-paginated-surface.c
parent60ffeecd4888fdf824b4095c945e1b27e05c0e1d (diff)
[test-paginated] Free resources if fail to create the test surface.
Ensure that all the locally allocated resources are freed if we fail to allocate the paginated test surface.
Diffstat (limited to 'src/test-paginated-surface.c')
-rw-r--r--src/test-paginated-surface.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c
index 3e9bad8c..7d341ad7 100644
--- a/src/test-paginated-surface.c
+++ b/src/test-paginated-surface.c
@@ -69,6 +69,7 @@ _cairo_test_paginated_surface_create_for_data (unsigned char *data,
{
cairo_status_t status;
cairo_surface_t *target;
+ cairo_surface_t *paginated;
test_paginated_surface_t *surface;
target = _cairo_image_surface_create_for_data_with_content (data, content,
@@ -80,6 +81,7 @@ _cairo_test_paginated_surface_create_for_data (unsigned char *data,
surface = malloc (sizeof (test_paginated_surface_t));
if (surface == NULL) {
+ cairo_surface_destroy (target);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t *) &_cairo_surface_nil;
}
@@ -89,8 +91,14 @@ _cairo_test_paginated_surface_create_for_data (unsigned char *data,
surface->target = target;
- return _cairo_paginated_surface_create (&surface->base, content, width, height,
- &test_paginated_surface_paginated_backend);
+ paginated = _cairo_paginated_surface_create (&surface->base,
+ content, width, height,
+ &test_paginated_surface_paginated_backend);
+ if (paginated->status) {
+ cairo_surface_destroy (target);
+ free (surface);
+ }
+ return paginated;
}
static cairo_status_t