mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-06 05:48:00 +02:00
[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.
This commit is contained in:
parent
60ffeecd48
commit
d2557cd5ee
1 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue