summaryrefslogtreecommitdiff
path: root/src/cairo-type3-glyph-surface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-04-10 14:55:24 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-04-16 09:34:03 +0100
commitd46bd67c8b3f63d6286845e814f8f1e040f89737 (patch)
tree15abb1d4a010519fef9922558cbbd3c5e7731f31 /src/cairo-type3-glyph-surface.c
parenta6ffb69a54f15659dac7c6b2e1c98bd7893ccdf1 (diff)
downloadcairo-d46bd67c8b3f63d6286845e814f8f1e040f89737.tar.gz
[type3] Add status checks.
Propagate error from the stream when creating the surface and add status guards before writing to the potential nil object.
Diffstat (limited to 'src/cairo-type3-glyph-surface.c')
-rw-r--r--src/cairo-type3-glyph-surface.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c
index c52915f77..2ffc01875 100644
--- a/src/cairo-type3-glyph-surface.c
+++ b/src/cairo-type3-glyph-surface.c
@@ -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;