mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-04 09:30:32 +01:00
[cairo-pdf-surface] Restore old_group for failed emit_meta_surface().
Ensure we restore the surface->current_group if we encounter an error during _cairo_pdf_surface_emit_meta_surface() lest we leak the current_group array.
This commit is contained in:
parent
8eb9fcf673
commit
8fa5f638a5
1 changed files with 16 additions and 11 deletions
|
|
@ -1576,12 +1576,13 @@ _cairo_pdf_surface_emit_meta_surface (cairo_pdf_surface_t *surface,
|
|||
|
||||
status = _cairo_pdf_surface_start_content_stream (surface);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
if (cairo_surface_get_content (meta_surface) == CAIRO_CONTENT_COLOR) {
|
||||
status = _cairo_pdf_surface_add_alpha (surface, 1.0, &alpha);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
_cairo_output_stream_printf (surface->output,
|
||||
"q /a%d gs 0 0 0 rg 0 0 %f %f re f Q\r\n",
|
||||
alpha,
|
||||
|
|
@ -1591,38 +1592,42 @@ _cairo_pdf_surface_emit_meta_surface (cairo_pdf_surface_t *surface,
|
|||
|
||||
status = _cairo_meta_surface_replay (meta_surface, &surface->base);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
status = _cairo_pdf_surface_stop_content_stream (surface);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
status = _cairo_pdf_surface_open_group (surface);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
status = _cairo_pdf_surface_write_group_list (surface, &group);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
status = _cairo_pdf_surface_close_group (surface, resource);
|
||||
if (status)
|
||||
return status;
|
||||
goto CLEANUP_GROUP;
|
||||
|
||||
CLEANUP_GROUP:
|
||||
surface->current_group = old_group;
|
||||
surface->width = old_width;
|
||||
surface->height = old_height;
|
||||
surface->cairo_to_pdf = old_cairo_to_pdf;
|
||||
|
||||
_cairo_pdf_group_element_array_finish (&group);
|
||||
_cairo_array_fini (&group);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
status = _cairo_pdf_surface_start_content_stream (surface);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
_cairo_pdf_group_element_array_finish (&group);
|
||||
_cairo_array_fini (&group);
|
||||
|
||||
_cairo_pdf_surface_pause_content_stream (surface);
|
||||
|
||||
return 0;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue