[cairo-commit] 5 commits - src/cairo-deflate-stream.c src/cairo-pdf-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Oct 4 15:39:47 PDT 2007


 src/cairo-deflate-stream.c |    6 +
 src/cairo-pdf-surface.c    |  258 +++++++++++++++++++++++++++++++++++----------
 2 files changed, 207 insertions(+), 57 deletions(-)

New commits:
diff-tree 853b29c56fdb50c627b27fc3a767300c7551dba0 (from 323511088d0c9057c1b0fa5e7aacda5e44e2e139)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 4 23:30:21 2007 +0100

    [cairo-pdf-surface] Add some missing error propagation.
    
    Add a couple of returns where the status was being assigned but not
    checked.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 81c6882..60ee04b 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -3337,6 +3337,10 @@ _cairo_pdf_surface_emit_outline_glyph (c
 					  _cairo_pdf_path_curve_to,
 					  _cairo_pdf_path_close_path,
 					  &info);
+    if (status) {
+	_cairo_pdf_surface_close_stream (surface);
+	return status;
+    }
 
     _cairo_output_stream_printf (surface->output,
 				 " f");
@@ -3655,16 +3659,18 @@ _cairo_pdf_surface_emit_font_subsets (ca
     status = _cairo_scaled_font_subsets_foreach_unscaled (surface->font_subsets,
                                                           _cairo_pdf_surface_emit_unscaled_font_subset,
                                                           surface);
+    if (status)
+	goto BAIL;
+
     status = _cairo_scaled_font_subsets_foreach_scaled (surface->font_subsets,
                                                         _cairo_pdf_surface_emit_scaled_font_subset,
                                                         surface);
+
+BAIL:
     _cairo_scaled_font_subsets_destroy (surface->font_subsets);
     surface->font_subsets = NULL;
 
-    if (status)
-	return status;
-
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 static cairo_pdf_resource_t
@@ -4360,6 +4366,8 @@ _cairo_pdf_surface_stroke (void			*abstr
 					  _cairo_pdf_path_curve_to,
 					  _cairo_pdf_path_close_path,
 					  &info);
+    if (status)
+	return status;
 
     _cairo_output_stream_printf (surface->output, "S Q\r\n");
 
@@ -4441,6 +4449,8 @@ _cairo_pdf_surface_fill (void			*abstrac
 					  _cairo_pdf_path_curve_to,
 					  _cairo_pdf_path_close_path,
 					  &info);
+    if (status)
+	return status;
 
     switch (fill_rule) {
     case CAIRO_FILL_RULE_WINDING:
diff-tree 323511088d0c9057c1b0fa5e7aacda5e44e2e139 (from 0e3f5caf9f0bbdb5acf34ae1b92eab32bf08acbf)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 4 23:22:49 2007 +0100

    [cairo-pdf-surface] Propagate errors from close_stream.
    
    Propagate the status return from _cairo_pdf_surface_close_stream().

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 04e1d45..81c6882 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1768,7 +1768,7 @@ _cairo_pdf_surface_emit_surface_pattern 
     surface->emitted_pattern.pattern = stream;
     surface->emitted_pattern.alpha = 1.0;
 
-    return status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 typedef struct _cairo_pdf_color_stop {
@@ -2075,7 +2075,10 @@ cairo_pdf_surface_emit_transparency_grou
                                  surface->width,
                                  surface->height);
 
-    _cairo_pdf_surface_close_stream (surface);
+    if (_cairo_pdf_surface_close_stream (surface)) {
+	smask_resource.id = 0;
+	return smask_resource;
+    }
 
     smask_resource = _cairo_pdf_surface_new_object (surface);
     if (smask_resource.id == 0)
@@ -3427,7 +3430,7 @@ _cairo_pdf_surface_emit_bitmap_glyph (ca
     if (image != scaled_glyph->surface)
 	cairo_surface_destroy (&image->base);
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 static void
@@ -3806,7 +3809,9 @@ _cairo_pdf_surface_write_page (cairo_pdf
     _cairo_output_stream_printf (surface->output,
 				 "/x%d Do\r\n",
 				 has_fallback_images ? knockout_group.id : content_group.id);
-    _cairo_pdf_surface_close_stream (surface);
+    status = _cairo_pdf_surface_close_stream (surface);
+    if (status)
+	return status;
 
     page = _cairo_pdf_surface_new_object (surface);
     if (page.id == 0)
diff-tree 0e3f5caf9f0bbdb5acf34ae1b92eab32bf08acbf (from 7940e39c1820b87c5b96dec6bc59eab97be4a793)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 4 23:18:33 2007 +0100

    [cairo-pdf-surface] Propagate errors during pattern selection.
    
    Propagate error from _cairo_pdf_surface_select_pattern ().

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index fd1736a..04e1d45 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2425,6 +2425,7 @@ _cairo_pdf_surface_select_pattern (cairo
     status = _cairo_pdf_surface_add_alpha (surface, surface->emitted_pattern.alpha, &alpha);
     if (status)
 	return status;
+
     if (surface->emitted_pattern.type == CAIRO_PATTERN_TYPE_SOLID) {
 	_cairo_output_stream_printf (surface->output,
                                      "%f %f %f ",
@@ -2450,7 +2451,9 @@ _cairo_pdf_surface_select_pattern (cairo
                                          "/Pattern cs /p%d scn ",
                                          surface->emitted_pattern.pattern.id);
         }
-        _cairo_pdf_surface_add_pattern (surface, surface->emitted_pattern.pattern);
+        status = _cairo_pdf_surface_add_pattern (surface, surface->emitted_pattern.pattern);
+	if (status)
+	    return status;
 
         _cairo_output_stream_printf (surface->output,
                                      "/a%d gs ",
@@ -2459,7 +2462,7 @@ _cairo_pdf_surface_select_pattern (cairo
         _cairo_output_stream_printf (surface->output, "\r\n");
     }
 
-    return CAIRO_STATUS_SUCCESS;
+    return _cairo_output_stream_get_status (surface->output);
 }
 
 static cairo_int_status_t
@@ -4020,7 +4023,9 @@ _cairo_pdf_surface_paint (void			*abstra
 	_cairo_output_stream_printf (surface->output, "q ");
     }
 
-    _cairo_pdf_surface_select_pattern (surface, FALSE);
+    status = _cairo_pdf_surface_select_pattern (surface, FALSE);
+    if (status)
+	return status;
 
     _cairo_output_stream_printf (surface->output,
 				 "0 0 %f %f re f\r\n",
@@ -4098,7 +4103,10 @@ _cairo_pdf_surface_mask	(void			*abstrac
     if (status)
 	return status;
 
-    _cairo_pdf_surface_select_pattern (surface, FALSE);
+    status = _cairo_pdf_surface_select_pattern (surface, FALSE);
+    if (status)
+	return status;
+
     _cairo_output_stream_printf (surface->output,
 				 "0 0 %f %f re f\r\n",
 				 surface->width, surface->height);
@@ -4139,7 +4147,10 @@ _cairo_pdf_surface_mask	(void			*abstrac
     if (status)
 	return status;
 
-    _cairo_pdf_surface_select_pattern (surface, FALSE);
+    status = _cairo_pdf_surface_select_pattern (surface, FALSE);
+    if (status)
+	return status;
+
     _cairo_output_stream_printf (surface->output,
 				 "0 0 %f %f re f\r\n",
 				 surface->width, surface->height);
@@ -4318,7 +4329,9 @@ _cairo_pdf_surface_stroke (void			*abstr
 	_cairo_output_stream_printf (surface->output, "q ");
     }
 
-    _cairo_pdf_surface_select_pattern (surface, TRUE);
+    status = _cairo_pdf_surface_select_pattern (surface, TRUE);
+    if (status)
+	return status;
 
     status = _cairo_pdf_surface_emit_stroke_style (surface,
 						   style);
@@ -4409,7 +4422,10 @@ _cairo_pdf_surface_fill (void			*abstrac
 	_cairo_output_stream_printf (surface->output, "q ");
     }
 
-    _cairo_pdf_surface_select_pattern (surface, FALSE);
+    status = _cairo_pdf_surface_select_pattern (surface, FALSE);
+    if (status)
+	return status;
+
     info.output = surface->output;
     info.cairo_to_pdf = &surface->cairo_to_pdf;
     info.ctm_inverse = NULL;
@@ -4501,7 +4517,9 @@ _cairo_pdf_surface_show_glyphs (void			*
 	_cairo_output_stream_printf (surface->output, "q ");
     }
 
-    _cairo_pdf_surface_select_pattern (surface, FALSE);
+    status = _cairo_pdf_surface_select_pattern (surface, FALSE);
+    if (status)
+	return status;
 
     _cairo_output_stream_printf (surface->output,
 				 "BT\r\n");
diff-tree 7940e39c1820b87c5b96dec6bc59eab97be4a793 (from 7601939a6524ad97a333fef910f3b5e69c46776c)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 4 23:15:21 2007 +0100

    [cairo-pdf-surface] Propagate errors from opening/closing groups.
    
    Propagate the any error encountered during _cairo_pdf_surface_open_group
    and friends.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 5139d6e..fd1736a 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -904,9 +904,11 @@ _cairo_pdf_surface_write_memory_stream (
     return group;
 }
 
-static void
+static cairo_status_t
 _cairo_pdf_surface_open_group (cairo_pdf_surface_t *surface)
 {
+    cairo_status_t status;
+
     assert (surface->pdf_stream.active == FALSE);
     assert (surface->content_stream.active == FALSE);
     assert (surface->group_stream.active == FALSE);
@@ -914,27 +916,40 @@ _cairo_pdf_surface_open_group (cairo_pdf
     surface->group_stream.active = TRUE;
 
     surface->group_stream.mem_stream = _cairo_memory_stream_create ();
+
     if (surface->compress_content) {
 	surface->group_stream.stream =
 	    _cairo_deflate_stream_create (surface->group_stream.mem_stream);
     } else {
 	surface->group_stream.stream = surface->group_stream.mem_stream;
     }
+    status = _cairo_output_stream_get_status (surface->group_stream.stream);
+    if (status)
+	return status;
 
     surface->group_stream.old_output = surface->output;
     surface->output = surface->group_stream.stream;
     _cairo_pdf_group_resources_clear (&surface->group_stream.resources);
     surface->current_resources = &surface->group_stream.resources;
     surface->group_stream.is_knockout = FALSE;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 _cairo_pdf_surface_open_knockout_group (cairo_pdf_surface_t  *surface,
 					cairo_pdf_resource_t *first_object)
 {
-    _cairo_pdf_surface_open_group (surface);
+    cairo_status_t status;
+
+    status = _cairo_pdf_surface_open_group (surface);
+    if (status)
+	return status;
+
     surface->group_stream.is_knockout = TRUE;
     surface->group_stream.first_object = *first_object;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -992,28 +1007,37 @@ _cairo_pdf_surface_write_group_list (cai
     _cairo_output_stream_printf (surface->output, "Q\r\n");
 }
 
-static void
+static cairo_status_t
 _cairo_pdf_surface_start_content_stream (cairo_pdf_surface_t *surface)
 {
-    if (surface->content_stream.active) {
-        return;
-    }
+    cairo_status_t status;
+
+    if (surface->content_stream.active)
+        return CAIRO_STATUS_SUCCESS;
+
     assert (surface->pdf_stream.active == FALSE);
     assert (surface->content_stream.active == FALSE);
     assert (surface->group_stream.active == FALSE);
 
     surface->content_stream.active = TRUE;
     surface->content_stream.mem_stream = _cairo_memory_stream_create ();
+
     if (surface->compress_content) {
 	surface->content_stream.stream =
 	    _cairo_deflate_stream_create (surface->content_stream.mem_stream);
     } else {
 	surface->content_stream.stream = surface->content_stream.mem_stream;
     }
+    status = _cairo_output_stream_get_status (surface->content_stream.stream);
+    if (status)
+	return status;
+
     surface->content_stream.old_output = surface->output;
     surface->output = surface->content_stream.stream;
     _cairo_pdf_group_resources_clear (&surface->content_stream.resources);
     surface->current_resources = &surface->content_stream.resources;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -1097,7 +1121,10 @@ _cairo_pdf_surface_check_content_stream_
 	status = _cairo_pdf_surface_stop_content_stream (surface);
 	if (status)
 	    return status;
-	_cairo_pdf_surface_start_content_stream (surface);
+
+	status = _cairo_pdf_surface_start_content_stream (surface);
+	if (status)
+	    return status;
     }
 
     return CAIRO_STATUS_SUCCESS;
@@ -1188,10 +1215,14 @@ _cairo_pdf_surface_finish (void *abstrac
 static cairo_int_status_t
 _cairo_pdf_surface_start_page (void *abstract_surface)
 {
+    cairo_status_t status;
     cairo_pdf_surface_t *surface = abstract_surface;
 
     surface->current_group = &surface->content_group;
-    _cairo_pdf_surface_start_content_stream (surface);
+    status = _cairo_pdf_surface_start_content_stream (surface);
+    if (status)
+	return status;
+
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1495,7 +1526,9 @@ _cairo_pdf_surface_emit_meta_surface (ca
 	return status;
 
     _cairo_pdf_surface_resume_content_stream (surface);
-    _cairo_pdf_surface_stop_content_stream (surface);
+    status = _cairo_pdf_surface_stop_content_stream (surface);
+    if (status)
+	return status;
 
     _cairo_array_init (&group, sizeof (cairo_pdf_group_element_t));
     old_group = surface->current_group;
@@ -1507,7 +1540,9 @@ _cairo_pdf_surface_emit_meta_surface (ca
     surface->height = meta_extents.height;
     cairo_matrix_init (&surface->cairo_to_pdf, 1, 0, 0, -1, 0, surface->height);
 
-    _cairo_pdf_surface_start_content_stream (surface);
+    status = _cairo_pdf_surface_start_content_stream (surface);
+    if (status)
+	return status;
 
     if (cairo_surface_get_content (meta_surface) == CAIRO_CONTENT_COLOR) {
 	status = _cairo_pdf_surface_add_alpha (surface, 1.0, &alpha);
@@ -1523,18 +1558,27 @@ _cairo_pdf_surface_emit_meta_surface (ca
     status = _cairo_meta_surface_replay (meta_surface, &surface->base);
     if (status)
 	return status;
-    _cairo_pdf_surface_stop_content_stream (surface);
+    status = _cairo_pdf_surface_stop_content_stream (surface);
+    if (status)
+	return status;
+
+    status = _cairo_pdf_surface_open_group (surface);
+    if (status)
+	return status;
 
-    _cairo_pdf_surface_open_group (surface);
     _cairo_pdf_surface_write_group_list (surface, &group);
-    _cairo_pdf_surface_close_group (surface, resource);
+    status = _cairo_pdf_surface_close_group (surface, resource);
+    if (status)
+	return status;
 
     surface->current_group = old_group;
     surface->width = old_width;
     surface->height = old_height;
     surface->cairo_to_pdf = old_cairo_to_pdf;
 
-    _cairo_pdf_surface_start_content_stream (surface);
+    status = _cairo_pdf_surface_start_content_stream (surface);
+    if (status)
+	return status;
 
     _cairo_pdf_group_element_array_finish (&group);
     _cairo_array_fini (&group);
@@ -2422,8 +2466,11 @@ static cairo_int_status_t
 _cairo_pdf_surface_copy_page (void *abstract_surface)
 {
     cairo_pdf_surface_t *surface = abstract_surface;
+    cairo_int_status_t status;
 
-    _cairo_pdf_surface_stop_content_stream (surface);
+    status = _cairo_pdf_surface_stop_content_stream (surface);
+    if (status)
+	return status;
 
     return _cairo_pdf_surface_write_page (surface);
 }
@@ -2434,7 +2481,9 @@ _cairo_pdf_surface_show_page (void *abst
     cairo_pdf_surface_t *surface = abstract_surface;
     cairo_int_status_t status;
 
-    _cairo_pdf_surface_stop_content_stream (surface);
+    status = _cairo_pdf_surface_stop_content_stream (surface);
+    if (status)
+	return status;
 
     status = _cairo_pdf_surface_write_page (surface);
     if (status)
@@ -2579,9 +2628,11 @@ _cairo_pdf_surface_add_clip (cairo_pdf_s
     if (status)
 	return status;
 
-    _cairo_pdf_surface_start_content_stream (surface);
+    status = _cairo_pdf_surface_start_content_stream (surface);
+    if (status)
+	return status;
 
-    return status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_int_status_t
@@ -3714,14 +3765,24 @@ _cairo_pdf_surface_write_page (cairo_pdf
     if (_cairo_array_num_elements (&surface->knockout_group) > 0)
 	has_fallback_images = TRUE;
 
-    _cairo_pdf_surface_open_group (surface);
+    status = _cairo_pdf_surface_open_group (surface);
+    if (status)
+	return status;
+
     _cairo_pdf_surface_write_group_list (surface, &surface->content_group);
-    _cairo_pdf_surface_close_group (surface, &content_group);
+    status = _cairo_pdf_surface_close_group (surface, &content_group);
+    if (status)
+	return status;
 
     if (has_fallback_images) {
-	_cairo_pdf_surface_open_knockout_group (surface, &content_group);
+	status = _cairo_pdf_surface_open_knockout_group (surface, &content_group);
+	if (status)
+	    return status;
+
 	_cairo_pdf_surface_write_group_list (surface, &surface->knockout_group);
-	_cairo_pdf_surface_close_group (surface, &knockout_group);
+	status = _cairo_pdf_surface_close_group (surface, &knockout_group);
+	if (status)
+	    return status;
     }
 
     page_content = _cairo_pdf_surface_open_stream (surface,
@@ -3907,13 +3968,21 @@ static cairo_int_status_t
 _cairo_pdf_surface_set_operator (cairo_pdf_surface_t *surface,
 				 cairo_operator_t op)
 {
+    cairo_status_t status;
+
     if (op == CAIRO_OPERATOR_OVER)
 	return CAIRO_STATUS_SUCCESS;
 
     if (op == CAIRO_OPERATOR_SOURCE) {
 	surface->current_group = &surface->knockout_group;
-	_cairo_pdf_surface_stop_content_stream (surface);
-	_cairo_pdf_surface_start_content_stream (surface);
+	status = _cairo_pdf_surface_stop_content_stream (surface);
+	if (status)
+	    return status;
+
+	status = _cairo_pdf_surface_start_content_stream (surface);
+	if (status)
+	    return status;
+
 	return CAIRO_STATUS_SUCCESS;
     }
 
@@ -3944,7 +4013,9 @@ _cairo_pdf_surface_paint (void			*abstra
 
     if (surface->emitted_pattern.smask.id != 0) {
 	_cairo_pdf_surface_pause_content_stream (surface);
-	_cairo_pdf_surface_open_group (surface);
+	status = _cairo_pdf_surface_open_group (surface);
+	if (status)
+	    return status;
     } else {
 	_cairo_output_stream_printf (surface->output, "q ");
     }
@@ -3956,7 +4027,10 @@ _cairo_pdf_surface_paint (void			*abstra
 				 surface->width, surface->height);
 
     if (surface->emitted_pattern.smask.id != 0) {
-	_cairo_pdf_surface_close_group (surface, &smask_group);
+	status = _cairo_pdf_surface_close_group (surface, &smask_group);
+	if (status)
+	    return status;
+
 	_cairo_pdf_surface_resume_content_stream (surface);
 	_cairo_output_stream_printf (surface->output,
 				     "q /s%d gs /x%d Do Q\r\n",
@@ -4020,16 +4094,24 @@ _cairo_pdf_surface_mask	(void			*abstrac
 
     _cairo_pdf_surface_pause_content_stream (surface);
 
-    _cairo_pdf_surface_open_group (surface);
+    status = _cairo_pdf_surface_open_group (surface);
+    if (status)
+	return status;
+
     _cairo_pdf_surface_select_pattern (surface, FALSE);
     _cairo_output_stream_printf (surface->output,
 				 "0 0 %f %f re f\r\n",
 				 surface->width, surface->height);
-    _cairo_pdf_surface_close_group (surface, &mask_group);
+    status = _cairo_pdf_surface_close_group (surface, &mask_group);
+    if (status)
+	return status;
 
     if (surface->emitted_pattern.smask.id != 0) {
 	group = mask_group;
-	_cairo_pdf_surface_open_group (surface);
+	status = _cairo_pdf_surface_open_group (surface);
+	if (status)
+	    return status;
+
 	_cairo_output_stream_printf (surface->output,
 				     "/s%d gs /x%d Do\r\n",
 				     surface->emitted_pattern.smask,
@@ -4040,7 +4122,10 @@ _cairo_pdf_surface_mask	(void			*abstrac
 	status = _cairo_pdf_surface_add_xobject (surface, group);
 	if (status)
 	    return status;
-	_cairo_pdf_surface_close_group (surface, &mask_group);
+
+	status = _cairo_pdf_surface_close_group (surface, &mask_group);
+	if (status)
+	    return status;
     }
 
     /* Create source group */
@@ -4050,16 +4135,24 @@ _cairo_pdf_surface_mask	(void			*abstrac
 
     _cairo_pdf_surface_pause_content_stream (surface);
 
-    _cairo_pdf_surface_open_group (surface);
+    status = _cairo_pdf_surface_open_group (surface);
+    if (status)
+	return status;
+
     _cairo_pdf_surface_select_pattern (surface, FALSE);
     _cairo_output_stream_printf (surface->output,
 				 "0 0 %f %f re f\r\n",
 				 surface->width, surface->height);
-    _cairo_pdf_surface_close_group (surface, &source_group);
+    status = _cairo_pdf_surface_close_group (surface, &source_group);
+    if (status)
+	return status;
 
     if (surface->emitted_pattern.smask.id != 0) {
 	group = source_group;
-	_cairo_pdf_surface_open_group (surface);
+	status = _cairo_pdf_surface_open_group (surface);
+	if (status)
+	    return status;
+
 	_cairo_output_stream_printf (surface->output,
 				     "/s%d gs /x%d Do\r\n",
 				     surface->emitted_pattern.smask,
@@ -4070,7 +4163,10 @@ _cairo_pdf_surface_mask	(void			*abstrac
 	status = _cairo_pdf_surface_add_xobject (surface, group);
 	if (status)
 	    return status;
-	_cairo_pdf_surface_close_group (surface, &source_group);
+
+	status =_cairo_pdf_surface_close_group (surface, &source_group);
+	if (status)
+	    return status;
     }
 
     /* Create an smask based on the alpha component of mask_group */
@@ -4215,7 +4311,9 @@ _cairo_pdf_surface_stroke (void			*abstr
 
     if (surface->emitted_pattern.smask.id != 0) {
 	_cairo_pdf_surface_pause_content_stream (surface);
-	_cairo_pdf_surface_open_group (surface);
+	status = _cairo_pdf_surface_open_group (surface);
+	if (status)
+	    return status;
     } else {
 	_cairo_output_stream_printf (surface->output, "q ");
     }
@@ -4248,7 +4346,10 @@ _cairo_pdf_surface_stroke (void			*abstr
     _cairo_output_stream_printf (surface->output, "S Q\r\n");
 
     if (surface->emitted_pattern.smask.id != 0) {
-	_cairo_pdf_surface_close_group (surface, &smask_group);
+	status = _cairo_pdf_surface_close_group (surface, &smask_group);
+	if (status)
+	    return status;
+
 	_cairo_pdf_surface_resume_content_stream (surface);
 	_cairo_output_stream_printf (surface->output,
 				     "q /s%d gs /x%d Do Q\r\n",
@@ -4301,7 +4402,9 @@ _cairo_pdf_surface_fill (void			*abstrac
 
     if (surface->emitted_pattern.smask.id != 0) {
 	_cairo_pdf_surface_pause_content_stream (surface);
-	_cairo_pdf_surface_open_group (surface);
+	status = _cairo_pdf_surface_open_group (surface);
+	if (status)
+	    return status;
     } else {
 	_cairo_output_stream_printf (surface->output, "q ");
     }
@@ -4334,7 +4437,10 @@ _cairo_pdf_surface_fill (void			*abstrac
 				 pdf_operator);
 
     if (surface->emitted_pattern.smask.id != 0) {
-	_cairo_pdf_surface_close_group (surface, &smask_group);
+	status = _cairo_pdf_surface_close_group (surface, &smask_group);
+	if (status)
+	    return status;
+
 	_cairo_pdf_surface_resume_content_stream (surface);
 	_cairo_output_stream_printf (surface->output,
 				     "q /s%d gs /x%d Do Q\r\n",
@@ -4388,7 +4494,9 @@ _cairo_pdf_surface_show_glyphs (void			*
 
     if (surface->emitted_pattern.smask.id != 0) {
 	_cairo_pdf_surface_pause_content_stream (surface);
-	_cairo_pdf_surface_open_group (surface);
+	status = _cairo_pdf_surface_open_group (surface);
+	if (status)
+	    return status;
     } else {
 	_cairo_output_stream_printf (surface->output, "q ");
     }
@@ -4537,7 +4645,10 @@ _cairo_pdf_surface_show_glyphs (void			*
 				 "ET\r\n");
 
     if (surface->emitted_pattern.smask.id != 0) {
-	_cairo_pdf_surface_close_group (surface, &smask_group);
+	status = _cairo_pdf_surface_close_group (surface, &smask_group);
+	if (status)
+	    return status;
+
 	_cairo_pdf_surface_resume_content_stream (surface);
 
 	_cairo_output_stream_printf (surface->output,
diff-tree 7601939a6524ad97a333fef910f3b5e69c46776c (from dbbcb5c26fba77d2a828b253c97e4770b81cf90b)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 4 23:07:36 2007 +0100

    [cairo-deflate-stream] Return the nil stream if creating from an error stream.
    
    If _cairo_deflate_stream_create() is passed a stream in the error state,
    return a stream also in the error state, namely the _cairo_output_stream_nil.

diff --git a/src/cairo-deflate-stream.c b/src/cairo-deflate-stream.c
index 73746fe..707832d 100644
--- a/src/cairo-deflate-stream.c
+++ b/src/cairo-deflate-stream.c
@@ -117,6 +117,12 @@ _cairo_deflate_stream_create (cairo_outp
 {
     cairo_deflate_stream_t *stream;
 
+    if (output->status) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+    }
+
+
     stream = malloc (sizeof (cairo_deflate_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);


More information about the cairo-commit mailing list