mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-03-06 17:30:38 +01:00
[type3] Add status checks.
Propagate error from the stream when creating the surface and add status guards before writing to the potential nil object.
This commit is contained in:
parent
a6ffb69a54
commit
d46bd67c8b
1 changed files with 23 additions and 3 deletions
|
|
@ -46,14 +46,17 @@
|
|||
static const cairo_surface_backend_t cairo_type3_glyph_surface_backend;
|
||||
|
||||
cairo_surface_t *
|
||||
_cairo_type3_glyph_surface_create (cairo_scaled_font_t *scaled_font,
|
||||
cairo_output_stream_t *stream,
|
||||
_cairo_type3_glyph_surface_create (cairo_scaled_font_t *scaled_font,
|
||||
cairo_output_stream_t *stream,
|
||||
cairo_type3_glyph_surface_emit_image_t emit_image,
|
||||
cairo_scaled_font_subsets_t *font_subsets)
|
||||
cairo_scaled_font_subsets_t *font_subsets)
|
||||
{
|
||||
cairo_type3_glyph_surface_t *surface;
|
||||
cairo_matrix_t invert_y_axis;
|
||||
|
||||
if (unlikely (stream != NULL && stream->status))
|
||||
return _cairo_surface_create_in_error (stream->status);
|
||||
|
||||
surface = malloc (sizeof (cairo_type3_glyph_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
|
@ -379,6 +382,9 @@ _cairo_type3_glyph_surface_set_font_subsets_callback (void *abstract
|
|||
{
|
||||
cairo_type3_glyph_surface_t *surface = abstract_surface;
|
||||
|
||||
if (unlikely (surface->base.status))
|
||||
return;
|
||||
|
||||
_cairo_pdf_operators_set_font_subsets_callback (&surface->pdf_operators,
|
||||
use_font_subset,
|
||||
closure);
|
||||
|
|
@ -393,7 +399,13 @@ _cairo_type3_glyph_surface_analyze_glyph (void *abstract_surface,
|
|||
cairo_status_t status, status2;
|
||||
cairo_output_stream_t *null_stream;
|
||||
|
||||
if (unlikely (surface->base.status))
|
||||
return surface->base.status;
|
||||
|
||||
null_stream = _cairo_null_stream_create ();
|
||||
if (unlikely (null_stream->status))
|
||||
return null_stream->status;
|
||||
|
||||
_cairo_type3_glyph_surface_set_stream (surface, null_stream);
|
||||
|
||||
_cairo_scaled_font_freeze_cache (surface->scaled_font);
|
||||
|
|
@ -446,6 +458,9 @@ _cairo_type3_glyph_surface_emit_glyph (void *abstract_surface,
|
|||
double x_advance, y_advance;
|
||||
cairo_matrix_t font_matrix_inverse;
|
||||
|
||||
if (unlikely (surface->base.status))
|
||||
return surface->base.status;
|
||||
|
||||
_cairo_type3_glyph_surface_set_stream (surface, stream);
|
||||
|
||||
_cairo_scaled_font_freeze_cache (surface->scaled_font);
|
||||
|
|
@ -496,6 +511,10 @@ _cairo_type3_glyph_surface_emit_glyph (void *abstract_surface,
|
|||
cairo_output_stream_t *mem_stream;
|
||||
|
||||
mem_stream = _cairo_memory_stream_create ();
|
||||
status = mem_stream->status;
|
||||
if (unlikely (status))
|
||||
goto FAIL;
|
||||
|
||||
_cairo_type3_glyph_surface_set_stream (surface, mem_stream);
|
||||
|
||||
_cairo_output_stream_printf (surface->stream, "q\n");
|
||||
|
|
@ -520,6 +539,7 @@ _cairo_type3_glyph_surface_emit_glyph (void *abstract_surface,
|
|||
if (status == CAIRO_INT_STATUS_IMAGE_FALLBACK)
|
||||
status = _cairo_type3_glyph_surface_emit_fallback_image (surface, glyph_index);
|
||||
|
||||
FAIL:
|
||||
_cairo_scaled_font_thaw_cache (surface->scaled_font);
|
||||
|
||||
return status;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue