[cairo] Add attribute(warn_unused_result)

Chris Wilson chris at chris-wilson.co.uk
Wed Mar 28 08:07:35 PDT 2007


A series of patches to propagate statuses which required changing
function types.
--
Chris Wilson
-------------- next part --------------
>From aeac341611e18208baa9f90296c8ebf8798e84ed Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 14:09:57 +0100
Subject: [PATCH] Catch and propagate out-of-memory status returns.

The skip list inserts could return NULL indicating an out-of-memory error.
In order to handle this, the error needs to propagate up the call stack.
---
 src/cairo-bentley-ottmann.c |   61 ++++++++++++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c
index 873bfd6..14308f8 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -137,6 +137,18 @@ typedef struct _cairo_bo_sweep_line {
     int32_t current_y;
 } cairo_bo_sweep_line_t;
 
+
+cairo_static cairo_status_t
+_cairo_bo_sweep_line_insert (cairo_bo_sweep_line_t	*sweep_line,
+			     cairo_bo_edge_t		*edge);
+cairo_static cairo_status_t
+_cairo_bo_event_queue_insert (cairo_bo_event_queue_t *queue,
+			      cairo_bo_event_t	     *event);
+cairo_static cairo_status_t
+_cairo_bo_event_queue_insert_if_intersect_below_current_y (cairo_bo_event_queue_t	*event_queue,
+							   cairo_bo_edge_t	*left,
+							   cairo_bo_edge_t	*right);
+
 static inline int
 _cairo_bo_point32_compare (cairo_bo_point32_t const *a,
 			   cairo_bo_point32_t const *b)
@@ -692,13 +704,16 @@ _cairo_bo_event_init (cairo_bo_event_t		*event,
     event->point = point;
 }
 
-static void
+static cairo_status_t
 _cairo_bo_event_queue_insert (cairo_bo_event_queue_t *queue,
 			      cairo_bo_event_t	     *event)
 {
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
     /* Don't insert if there's already an equivalent intersection event in the queue. */
-    _cairo_skip_list_insert (&queue->intersection_queue, event,
-		      event->type == CAIRO_BO_EVENT_TYPE_INTERSECTION);
+    if (_cairo_skip_list_insert (&queue->intersection_queue, event,
+		      event->type == CAIRO_BO_EVENT_TYPE_INTERSECTION) == NULL)
+	status = CAIRO_STATUS_NO_MEMORY;
+    return status;
 }
 
 static void
@@ -796,7 +811,7 @@ _cairo_bo_event_queue_fini (cairo_bo_event_queue_t *event_queue)
 	free (event_queue->sorted_startstop_event_ptrs);
 }
 
-static void
+static cairo_status_t
 _cairo_bo_event_queue_insert_if_intersect_below_current_y (cairo_bo_event_queue_t	*event_queue,
 							   cairo_bo_edge_t	*left,
 							   cairo_bo_edge_t	*right)
@@ -806,7 +821,7 @@ _cairo_bo_event_queue_insert_if_intersect_below_current_y (cairo_bo_event_queue_
     cairo_bo_event_t event;
 
     if (left == NULL || right == NULL)
-	return;
+	return CAIRO_STATUS_SUCCESS;
 
     /* The names "left" and "right" here are correct descriptions of
      * the order of the two edges within the active edge list. So if a
@@ -814,13 +829,13 @@ _cairo_bo_event_queue_insert_if_intersect_below_current_y (cairo_bo_event_queue_
      * that the intersection of these two segments has oalready
      * occurred before the current sweep line position. */
     if (_slope_compare (left, right) < 0)
-	return;
+	return CAIRO_STATUS_SUCCESS;
 
     status = _cairo_bo_edge_intersect (left, right, &intersection);
     if (status == CAIRO_BO_STATUS_PARALLEL ||
 	status == CAIRO_BO_STATUS_NO_INTERSECTION)
     {
-	return;
+	return CAIRO_STATUS_SUCCESS;
     }
 
     _cairo_bo_event_init (&event,
@@ -828,7 +843,7 @@ _cairo_bo_event_queue_insert_if_intersect_below_current_y (cairo_bo_event_queue_
 			  left, right,
 			  intersection);
 
-    _cairo_bo_event_queue_insert (event_queue, &event);
+    return _cairo_bo_event_queue_insert (event_queue, &event);
 }
 
 static void
@@ -848,7 +863,7 @@ _cairo_bo_sweep_line_fini (cairo_bo_sweep_line_t *sweep_line)
     _cairo_skip_list_fini (&sweep_line->active_edges);
 }
 
-static void
+static cairo_status_t
 _cairo_bo_sweep_line_insert (cairo_bo_sweep_line_t	*sweep_line,
 			     cairo_bo_edge_t		*edge)
 {
@@ -858,6 +873,8 @@ _cairo_bo_sweep_line_insert (cairo_bo_sweep_line_t	*sweep_line,
 
     sweep_line_elt = _cairo_skip_list_insert (&sweep_line->active_edges, &edge,
 				       1 /* unique inserts*/);
+    if (sweep_line_elt == NULL)
+	return CAIRO_STATUS_NO_MEMORY;
 
     next_elt = sweep_line_elt->elt.next[0];
     if (next_elt)
@@ -876,6 +893,8 @@ _cairo_bo_sweep_line_insert (cairo_bo_sweep_line_t	*sweep_line,
     *next_of_prev = edge;
 
     edge->sweep_line_elt = sweep_line_elt;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -1296,7 +1315,9 @@ _cairo_bentley_ottmann_tessellate_bo_edges (cairo_bo_edge_t	*edges,
 	case CAIRO_BO_EVENT_TYPE_START:
 	    edge = event->e1;
 
-	    _cairo_bo_sweep_line_insert (&sweep_line, edge);
+	    status = _cairo_bo_sweep_line_insert (&sweep_line, edge);
+	    if (status)
+		goto unwind;
 	    /* Cache the insert position for use in pass 2.
 	    event->e2 = Sortlist::prev (sweep_line, edge);
 	    */
@@ -1304,9 +1325,13 @@ _cairo_bentley_ottmann_tessellate_bo_edges (cairo_bo_edge_t	*edges,
 	    left = edge->prev;
 	    right = edge->next;
 
-	    _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue, left, edge);
+	    status = _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue, left, edge);
+	    if (status)
+		goto unwind;
 
-	    _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue, edge, right);
+	    status = _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue, edge, right);
+	    if (status)
+		goto unwind;
 
 #if DEBUG_PRINT_STATE
 	    print_state ("After processing start", &event_queue, &sweep_line);
@@ -1326,7 +1351,9 @@ _cairo_bentley_ottmann_tessellate_bo_edges (cairo_bo_edge_t	*edges,
 	    if (status)
 		goto unwind;
 
-	    _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue, left, right);
+	    status = _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue, left, right);
+	    if (status)
+		goto unwind;
 
 #if DEBUG_PRINT_STATE
 	    print_state ("After processing stop", &event_queue, &sweep_line);
@@ -1354,11 +1381,15 @@ _cairo_bentley_ottmann_tessellate_bo_edges (cairo_bo_edge_t	*edges,
 
 	    /* after the swap e2 is left of e1 */
 
-	    _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue,
+	    status = _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue,
 								       left, edge2);
+	    if (status)
+		goto unwind;
 
-	    _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue,
+	    status = _cairo_bo_event_queue_insert_if_intersect_below_current_y (&event_queue,
 								       edge1, right);
+	    if (status)
+		goto unwind;
 
 #if DEBUG_PRINT_STATE
 	    print_state ("After processing intersection", &event_queue, &sweep_line);
-- 
1.4.4.2

-------------- next part --------------
>From 0d8d5639b5379490bfdcf84bf1b627a1118960d7 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 14:37:18 +0100
Subject: [PATCH] pixman region operations can fail, propagate the error.

Copying the clip region could fail, add error returns and propagate up
the call stack.
---
 src/cairo-clip-private.h |    4 ++--
 src/cairo-clip.c         |   39 +++++++++++++++++++++++++++++++++------
 src/cairo-gstate.c       |   14 +++++++++++---
 src/cairo.c              |    2 +-
 src/cairoint.h           |    2 +-
 5 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index 3c4ff0d..81482ff 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -86,10 +86,10 @@ _cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target);
 cairo_private void
 _cairo_clip_fini (cairo_clip_t *clip);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
                             cairo_clip_t    *other,
                             cairo_surface_t *target);
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 0ab036b..de4bd23 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -82,7 +82,7 @@ _cairo_clip_fini (cairo_clip_t *clip)
     clip->path = NULL;
 }
 
-void
+cairo_status_t
 _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
 {
     clip->mode = other->mode;
@@ -96,10 +96,21 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
 	clip->region = other->region;
     } else {
 	clip->region = pixman_region_create ();
-	pixman_region_copy (clip->region, other->region);
+	if (clip->region == NULL) {
+	    cairo_surface_destroy (clip->surface);
+	    return CAIRO_STATUS_NO_MEMORY;
+	}
+	if (pixman_region_copy (clip->region, other->region) !=
+		PIXMAN_REGION_STATUS_SUCCESS) {
+	    pixman_region_destroy (clip->region);
+	    cairo_surface_destroy (clip->surface);
+	    return CAIRO_STATUS_NO_MEMORY;
+	}
     }
 
     clip->path = _cairo_clip_path_reference (other->path);
+    
+    return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_status_t
@@ -553,7 +564,7 @@ _cairo_clip_path_reapply_clip_path (cairo_clip_t      *clip,
                                 clip_path->antialias);
 }
 
-void
+cairo_status_t
 _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
                             cairo_clip_t    *other,
                             cairo_surface_t *target)
@@ -566,16 +577,22 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
     } else {
         if (other->region) {
             clip->region = pixman_region_create ();
-            pixman_region_copy (clip->region, other->region);
+	    if (clip->region == NULL)
+		goto BAIL;
+            if (pixman_region_copy (clip->region, other->region) !=
+		    PIXMAN_REGION_STATUS_SUCCESS)
+		goto BAIL;
         }
 
         if (other->surface) {
-            _cairo_surface_clone_similar (target, other->surface,
+            if (_cairo_surface_clone_similar (target, other->surface,
 					  other->surface_rect.x,
 					  other->surface_rect.y,
 					  other->surface_rect.width,
 					  other->surface_rect.height,
-					  &clip->surface);
+					  &clip->surface) !=
+		    CAIRO_STATUS_SUCCESS)
+		goto BAIL;
             clip->surface_rect = other->surface_rect;
         }
 
@@ -583,6 +600,16 @@ _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
             _cairo_clip_path_reapply_clip_path (clip, other->path);
         }
     }
+
+    return CAIRO_STATUS_SUCCESS;
+
+BAIL:
+    if (clip->region)
+	pixman_region_destroy (clip->region);
+    if (clip->surface)
+	cairo_surface_destroy (clip->surface);
+
+    return CAIRO_STATUS_NO_MEMORY;
 }
 
 const cairo_rectangle_list_t _cairo_rectangles_nil =
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 5647f9c..82f5402 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -134,7 +134,9 @@ _cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other)
 
     _cairo_font_options_init_copy (&gstate->font_options , &other->font_options);
 
-    _cairo_clip_init_copy (&gstate->clip, &other->clip);
+    status = _cairo_clip_init_copy (&gstate->clip, &other->clip);
+    if (status)
+	return status;
 
     gstate->target = cairo_surface_reference (other->target);
     /* parent_target is always set to NULL; it's only ever set by redirect_target */
@@ -304,9 +306,11 @@ _cairo_gstate_recursive_apply_clip_path (cairo_gstate_t *gstate,
  * original #cairo_t target, the clip will be INVALID after this call,
  * and the caller should either recreate or reset the clip.
  **/
-void
+cairo_status_t
 _cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child)
 {
+    cairo_status_t status;
+
     /* If this gstate is already redirected, this is an error; we need a
      * new gstate to be able to redirect */
     assert (gstate->parent_target == NULL);
@@ -322,13 +326,17 @@ _cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child)
     gstate->target = cairo_surface_reference (child);
 
     _cairo_clip_fini (&gstate->clip);
-    _cairo_clip_init_deep_copy (&gstate->clip, &gstate->next->clip, child);
+    status = _cairo_clip_init_deep_copy (&gstate->clip, &gstate->next->clip, child);
+    if (status)
+	return status;
 
     /* The clip is in surface backend coordinates for the previous target;
      * translate it into the child's backend coordinates. */
     _cairo_clip_translate (&gstate->clip,
                            _cairo_fixed_from_double (child->device_transform.x0 - gstate->parent_target->device_transform.x0),
                            _cairo_fixed_from_double (child->device_transform.y0 - gstate->parent_target->device_transform.y0));
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 /**
diff --git a/src/cairo.c b/src/cairo.c
index b8a0419..64b2b0b 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -517,7 +517,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
     if (cr->status)
 	goto bail;
 
-    _cairo_gstate_redirect_target (cr->gstate, group_surface);
+    status = _cairo_gstate_redirect_target (cr->gstate, group_surface);
 
 bail:
     cairo_surface_destroy (group_surface);
diff --git a/src/cairoint.h b/src/cairoint.h
index ed685e6..9aa50ff 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1259,7 +1259,7 @@ _cairo_gstate_restore (cairo_gstate_t **gstate);
 cairo_private cairo_bool_t
 _cairo_gstate_is_redirected (cairo_gstate_t *gstate);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child);
 
 cairo_private cairo_surface_t *
-- 
1.4.4.2

-------------- next part --------------
>From 9873c2a418789dba375f74fe19dcbb182ee2f8ac Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 14:50:59 +0100
Subject: [PATCH] pixman_composite can fail, propagate the error status.

---
 src/cairo-image-surface.c |   42 +++++++++++++++++++++++++++---------------
 src/cairo-pattern.c       |   20 ++++++++++++--------
 2 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 3062533..a122fa3 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -848,7 +848,7 @@ _cairo_image_surface_composite (cairo_operator_t	op,
 	if (status)
 	    goto CLEANUP_SURFACES;
 
-	pixman_composite (_pixman_operator (op),
+	if (pixman_composite (_pixman_operator (op),
 			  src->pixman_image,
 			  mask->pixman_image,
 			  dst->pixman_image,
@@ -857,11 +857,14 @@ _cairo_image_surface_composite (cairo_operator_t	op,
 			  mask_x + mask_attr.x_offset,
 			  mask_y + mask_attr.y_offset,
 			  dst_x, dst_y,
-			  width, height);
+			  width, height)) {
+	    status = CAIRO_STATUS_NO_MEMORY;
+	    goto CLEANUP_SURFACES;
+	}
     }
     else
     {
-	pixman_composite (_pixman_operator (op),
+	if (pixman_composite (_pixman_operator (op),
 			  src->pixman_image,
 			  NULL,
 			  dst->pixman_image,
@@ -869,7 +872,10 @@ _cairo_image_surface_composite (cairo_operator_t	op,
 			  src_y + src_attr.y_offset,
 			  0, 0,
 			  dst_x, dst_y,
-			  width, height);
+			  width, height)) {
+	    status = CAIRO_STATUS_NO_MEMORY;
+	    goto CLEANUP_SURFACES;
+	}
     }
 
     if (!_cairo_operator_bounded_by_source (op))
@@ -908,8 +914,11 @@ _cairo_image_surface_fill_rectangles (void		      *abstract_surface,
     pixman_color.alpha = color->alpha_short;
 
     /* XXX: The pixman_rectangle_t cast is evil... it needs to go away somehow. */
-    pixman_fill_rectangles (_pixman_operator(op), surface->pixman_image,
-			    &pixman_color, (pixman_rectangle_t *) rects, num_rects);
+    if (pixman_fill_rectangles (_pixman_operator(op), surface->pixman_image,
+			        &pixman_color,
+			        (pixman_rectangle_t *) rects, num_rects)) {
+	return CAIRO_STATUS_NO_MEMORY;
+    }
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1014,15 +1023,18 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
     pixman_add_trapezoids (mask, - dst_x, - dst_y,
 			   (pixman_trapezoid_t *) traps, num_traps);
 
-    pixman_composite (_pixman_operator (op),
-		      src->pixman_image,
-		      mask,
-		      dst->pixman_image,
-		      src_x + attributes.x_offset,
-		      src_y + attributes.y_offset,
-		      0, 0,
-		      dst_x, dst_y,
-		      width, height);
+    if (pixman_composite (_pixman_operator (op),
+		          src->pixman_image,
+			  mask,
+			  dst->pixman_image,
+			  src_x + attributes.x_offset,
+			  src_y + attributes.y_offset,
+			  0, 0,
+			  dst_x, dst_y,
+			  width, height)) {
+	status = CAIRO_STATUS_NO_MEMORY;
+	goto CLEANUP_IMAGE_DATA;
+    }
 
     if (!_cairo_operator_bounded_by_mask (op))
 	status = _cairo_surface_composite_shape_fixup_unbounded (&dst->base,
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 3001e10..570527d 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1212,14 +1212,18 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
 	break;
     }
 
-    pixman_composite (PIXMAN_OPERATOR_SRC,
-		      pixman_image,
-		      NULL,
-		      image->pixman_image,
-		      x, y,
-		      0, 0,
-		      0, 0,
-		      width, height);
+    if (pixman_composite (PIXMAN_OPERATOR_SRC,
+		          pixman_image,
+			  NULL,
+			  image->pixman_image,
+			  x, y,
+			  0, 0,
+			  0, 0,
+			  width, height)) {
+	cairo_surface_destroy (&image->base);
+	pixman_image_destroy (pixman_image);
+	return CAIRO_STATUS_NO_MEMORY;
+    }
 
     pixman_image_destroy (pixman_image);
 
-- 
1.4.4.2

-------------- next part --------------
>From 2b9f65d2860f3bbfa81c49179ffef031657ead81 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 14:57:44 +0100
Subject: [PATCH] cairo_pen_init() can fail propagate its error.

---
 src/cairo-path-stroke.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 3aeb41f..4dd96b0 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -67,7 +67,7 @@ typedef struct cairo_stroker {
 } cairo_stroker_t;
 
 /* private functions */
-static void
+cairo_static cairo_status_t
 _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     cairo_stroke_style_t	*stroke_style,
 		     cairo_matrix_t		*ctm,
@@ -75,40 +75,40 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     double			 tolerance,
 		     cairo_traps_t		*traps);
 
-static void
+cairo_static void
 _cairo_stroker_fini (cairo_stroker_t *stroker);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_move_to (void *closure, cairo_point_t *point);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_line_to (void *closure, cairo_point_t *point);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_curve_to (void *closure,
 			 cairo_point_t *b,
 			 cairo_point_t *c,
 			 cairo_point_t *d);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_curve_to_dashed (void *closure,
 				cairo_point_t *b,
 				cairo_point_t *c,
 				cairo_point_t *d);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_close_path (void *closure);
 
-static void
+cairo_static void
 _translate_point (cairo_point_t *point, cairo_point_t *offset);
 
-static int
+cairo_static int
 _cairo_stroker_face_clockwise (cairo_stroke_face_t *in, cairo_stroke_face_t *out);
 
-static cairo_status_t
+cairo_static cairo_status_t
 _cairo_stroker_join (cairo_stroker_t *stroker, cairo_stroke_face_t *in, cairo_stroke_face_t *out);
 
 static void
@@ -148,7 +148,7 @@ _cairo_stroker_step_dash (cairo_stroker_t *stroker, double step)
     }
 }
 
-static void
+static cairo_status_t
 _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     cairo_stroke_style_t	*stroke_style,
 		     cairo_matrix_t		*ctm,
@@ -156,15 +156,18 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     double			 tolerance,
 		     cairo_traps_t		*traps)
 {
+    cairo_status_t status;
     stroker->style = stroke_style;
     stroker->ctm = ctm;
     stroker->ctm_inverse = ctm_inverse;
     stroker->tolerance = tolerance;
     stroker->traps = traps;
 
-    _cairo_pen_init (&stroker->pen,
-		     stroke_style->line_width / 2.0,
-		     tolerance, ctm);
+    status = _cairo_pen_init (&stroker->pen,
+		              stroke_style->line_width / 2.0,
+			      tolerance, ctm);
+    if (status)
+	return status;
 
     stroker->has_current_face = FALSE;
     stroker->has_first_face = FALSE;
@@ -174,6 +177,8 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
 	_cairo_stroker_start_dash (stroker);
     else
 	stroker->dashed = FALSE;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -995,9 +1000,11 @@ _cairo_path_fixed_stroke_to_traps (cairo_path_fixed_t	*path,
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	return status;
 
-    _cairo_stroker_init (&stroker, stroke_style,
-			 ctm, ctm_inverse, tolerance,
-			 traps);
+    status = _cairo_stroker_init (&stroker, stroke_style,
+			          ctm, ctm_inverse, tolerance,
+				  traps);
+    if (status)
+	return status;
 
     if (stroker.style->dash)
 	status = _cairo_path_fixed_interpret (path,
-- 
1.4.4.2

-------------- next part --------------
>From 096461a0a558a7e37d1bac3151e2d2323fb4ee75 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 15:05:39 +0100
Subject: [PATCH] pen finalization can fail, propagate its status.

---
 src/cairo-path-stroke.c |   18 +++++++++++-------
 src/cairo-pen.c         |    4 ++--
 src/cairoint.h          |    2 +-
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 4dd96b0..aa8ce38 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -75,7 +75,7 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
 		     double			 tolerance,
 		     cairo_traps_t		*traps);
 
-cairo_static void
+cairo_static cairo_status_t
 _cairo_stroker_fini (cairo_stroker_t *stroker);
 
 cairo_static cairo_status_t
@@ -181,10 +181,10 @@ _cairo_stroker_init (cairo_stroker_t		*stroker,
     return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 _cairo_stroker_fini (cairo_stroker_t *stroker)
 {
-    _cairo_pen_fini (&stroker->pen);
+    return _cairo_pen_fini (&stroker->pen);
 }
 
 static void
@@ -811,7 +811,7 @@ _cairo_stroker_curve_to (void *closure,
 			 cairo_point_t *c,
 			 cairo_point_t *d)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status = CAIRO_STATUS_SUCCESS, status2;
     cairo_stroker_t *stroker = closure;
     cairo_spline_t spline;
     cairo_pen_t pen;
@@ -863,7 +863,9 @@ _cairo_stroker_curve_to (void *closure,
 	goto CLEANUP_PEN;
 
   CLEANUP_PEN:
-    _cairo_pen_fini (&pen);
+    status2 = _cairo_pen_fini (&pen);
+    if (status == CAIRO_STATUS_SUCCESS)
+	status = status2;
   CLEANUP_SPLINE:
     _cairo_spline_fini (&spline);
 
@@ -985,7 +987,7 @@ _cairo_path_fixed_stroke_to_traps (cairo_path_fixed_t	*path,
 				   double		 tolerance,
 				   cairo_traps_t	*traps)
 {
-    cairo_status_t status;
+    cairo_status_t status, status2;
     cairo_stroker_t stroker;
 
     /* Before we do anything else, we attempt the rectilinear
@@ -1029,7 +1031,9 @@ _cairo_path_fixed_stroke_to_traps (cairo_path_fixed_t	*path,
     status = _cairo_stroker_add_caps (&stroker);
 
 BAIL:
-    _cairo_stroker_fini (&stroker);
+    status2 = _cairo_stroker_fini (&stroker);
+    if (status == CAIRO_STATUS_SUCCESS)
+	status = status2;
 
     return status;
 }
diff --git a/src/cairo-pen.c b/src/cairo-pen.c
index 1bc096b..74d2996 100644
--- a/src/cairo-pen.c
+++ b/src/cairo-pen.c
@@ -106,13 +106,13 @@ _cairo_pen_init (cairo_pen_t	*pen,
     return CAIRO_STATUS_SUCCESS;
 }
 
-void
+cairo_status_t
 _cairo_pen_fini (cairo_pen_t *pen)
 {
     free (pen->vertices);
     pen->vertices = NULL;
 
-    _cairo_pen_init_empty (pen);
+    return _cairo_pen_init_empty (pen);
 }
 
 cairo_status_t
diff --git a/src/cairoint.h b/src/cairoint.h
index 9aa50ff..cef52fc 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2186,7 +2186,7 @@ _cairo_pen_init_empty (cairo_pen_t *pen);
 cairo_private cairo_status_t
 _cairo_pen_init_copy (cairo_pen_t *pen, cairo_pen_t *other);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_pen_fini (cairo_pen_t *pen);
 
 cairo_private cairo_status_t
-- 
1.4.4.2

-------------- next part --------------
>From 2ab24f2827cd29c3d3b05cba8097b3b018105152 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 15:27:04 +0100
Subject: [PATCH] Matrix transformation could fail, so propagate its error status.

---
 src/cairo-ft-font.c     |   90 ++++++++++++++++++++++++++++++++++------------
 src/cairo-scaled-font.c |   13 +++++--
 src/cairoint.h          |    2 +-
 3 files changed, 76 insertions(+), 29 deletions(-)

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 73a40f8..d30628a 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -106,13 +106,20 @@ struct _cairo_ft_unscaled_font {
     cairo_ft_font_face_t *faces;	/* Linked list of faces for this font */
 };
 
-static int
+cairo_static cairo_status_t
+_compute_transform (cairo_ft_font_transform_t *sf,
+		    cairo_matrix_t      *scale);
+
+cairo_static int
 _cairo_ft_unscaled_font_keys_equal (const void *key_a,
 				    const void *key_b);
-
-static void
+cairo_static void
 _cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled);
 
+cairo_static cairo_status_t
+_cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
+				   cairo_matrix_t	      *scale);
+
 typedef enum _cairo_ft_extra_flags {
     CAIRO_FT_OPTIONS_HINT_METRICS = (1 << 0),
     CAIRO_FT_OPTIONS_EMBOLDEN = (1 << 1)
@@ -572,12 +579,13 @@ _cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled)
 }
 slim_hidden_def (cairo_ft_scaled_font_unlock_face);
 
-static void
+static cairo_status_t
 _compute_transform (cairo_ft_font_transform_t *sf,
 		    cairo_matrix_t      *scale)
 {
     cairo_matrix_t normalized = *scale;
     double tx, ty;
+    cairo_status_t status;
 
     /* The font matrix has x and y "scale" components which we extract and
      * use as character scale values. These influence the way freetype
@@ -586,9 +594,11 @@ _compute_transform (cairo_ft_font_transform_t *sf,
      * freetype's transformation.
      */
 
-    _cairo_matrix_compute_scale_factors (&normalized,
-					 &sf->x_scale, &sf->y_scale,
-					 /* XXX */ 1);
+    status = _cairo_matrix_compute_scale_factors (&normalized,
+					          &sf->x_scale, &sf->y_scale,
+					          /* XXX */ 1);
+    if (status)
+	return status;
 
     if (sf->x_scale != 0 && sf->y_scale != 0) {
 	cairo_matrix_scale (&normalized, 1.0 / sf->x_scale, 1.0 / sf->y_scale);
@@ -601,16 +611,19 @@ _compute_transform (cairo_ft_font_transform_t *sf,
 	sf->shape[0][0] = sf->shape[1][1] = 1.0;
 	sf->shape[0][1] = sf->shape[1][0] = 0.0;
     }
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 /* Temporarily scales an unscaled font to the give scale. We catch
  * scaling to the same size, since changing a FT_Face is expensive.
  */
-static void
+static cairo_status_t
 _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
 				   cairo_matrix_t	      *scale)
 {
     cairo_ft_font_transform_t sf;
+    cairo_status_t status;
     FT_Matrix mat;
     FT_Error error;
 
@@ -621,12 +634,14 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
 	scale->yx == unscaled->current_scale.yx &&
 	scale->xy == unscaled->current_scale.xy &&
 	scale->yy == unscaled->current_scale.yy)
-	return;
+	return CAIRO_STATUS_SUCCESS;
 
     unscaled->have_scale = TRUE;
     unscaled->current_scale = *scale;
 
-    _compute_transform (&sf, scale);
+    status = _compute_transform (&sf, scale);
+    if (status)
+	return status;
 
     unscaled->x_scale = sf.x_scale;
     unscaled->y_scale = sf.y_scale;
@@ -654,6 +669,8 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
 				  sf.x_scale * 64.0,
 				  sf.y_scale * 64.0,
 				  0, 0);
+	if (error)
+	    status = CAIRO_STATUS_NO_MEMORY;
 	assert (error == 0);
     } else {
 	double min_distance = DBL_MAX;
@@ -683,8 +700,12 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
 	    error = FT_Set_Pixel_Sizes (unscaled->face,
 					unscaled->face->available_sizes[best_i].width,
 					unscaled->face->available_sizes[best_i].height);
+	if (error)
+	    status = CAIRO_STATUS_NO_MEMORY;
 	assert (error == 0);
     }
+
+    return status;
 }
 
 /* Empirically-derived subpixel filtering values thanks to Keith
@@ -1461,8 +1482,13 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
 	return NULL;
     }
 
-    _cairo_ft_unscaled_font_set_scale (unscaled,
-				       &scaled_font->base.scale);
+    status = _cairo_ft_unscaled_font_set_scale (unscaled,
+				                &scaled_font->base.scale);
+    if (status) {
+	free (scaled_font);
+	_cairo_ft_unscaled_font_unlock_face (unscaled);
+	return NULL;
+    }
 
     metrics = &face->size->metrics;
 
@@ -1508,7 +1534,12 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
 	}
     }
 
-    _cairo_scaled_font_set_metrics (&scaled_font->base, &fs_metrics);
+    status = _cairo_scaled_font_set_metrics (&scaled_font->base, &fs_metrics);
+    if (status) {
+	free (scaled_font);
+	_cairo_ft_unscaled_font_unlock_face (unscaled);
+	return NULL;
+    }
 
     _cairo_ft_unscaled_font_unlock_face (unscaled);
 
@@ -1536,6 +1567,7 @@ _cairo_ft_scaled_font_create_toy (cairo_toy_font_face_t	      *toy_face,
     int fcweight;
     cairo_matrix_t scale;
     cairo_ft_font_transform_t sf;
+    cairo_status_t status;
     cairo_ft_options_t ft_options;
     unsigned char *family = (unsigned char*) toy_face->family;
 
@@ -1576,7 +1608,9 @@ _cairo_ft_scaled_font_create_toy (cairo_toy_font_face_t	      *toy_face,
 	goto FREE_PATTERN;
 
     cairo_matrix_multiply (&scale, font_matrix, ctm);
-    _compute_transform (&sf, &scale);
+    status = _compute_transform (&sf, &scale);
+    if (status)
+	goto FREE_PATTERN;
 
     FcPatternAddInteger (pattern, FC_PIXEL_SIZE, sf.y_scale);
 
@@ -1749,18 +1783,18 @@ _decompose_glyph_outline (FT_Face		  face,
 
     glyph = face->glyph;
 
-    status = CAIRO_STATUS_SUCCESS;
     /* Font glyphs have an inverted Y axis compared to cairo. */
     FT_Outline_Transform (&glyph->outline, &invert_y);
     if (FT_Outline_Decompose (&glyph->outline, &outline_funcs, path))
-	status = CAIRO_STATUS_NO_MEMORY;
+	return CAIRO_STATUS_NO_MEMORY;
 
-    _cairo_path_fixed_close_path (path);
+    status = _cairo_path_fixed_close_path (path);
+    if (status)
+	return status;
 
-    if (status == CAIRO_STATUS_SUCCESS)
-	*pathp = path;
+    *pathp = path;
 
-    return status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 /*
@@ -1806,8 +1840,10 @@ _cairo_ft_scaled_glyph_init (void			*abstract_font,
     if (!face)
 	return CAIRO_STATUS_NO_MEMORY;
 
-    _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
-				       &scaled_font->base.scale);
+    status = _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
+				                &scaled_font->base.scale);
+    if (status)
+	goto FAIL;
 
     /* Ignore global advance unconditionally */
     load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
@@ -2474,6 +2510,7 @@ cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *abstract_font)
 {
     cairo_ft_scaled_font_t *scaled_font = (cairo_ft_scaled_font_t *) abstract_font;
     FT_Face face;
+    cairo_status_t status;
 
     if (scaled_font->base.status)
 	return NULL;
@@ -2484,8 +2521,13 @@ cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *abstract_font)
 	return NULL;
     }
 
-    _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
-				       &scaled_font->base.scale);
+    status = _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
+				                &scaled_font->base.scale);
+    if (status) {
+	_cairo_ft_unscaled_font_unlock_face (scaled_font->unscaled);
+	_cairo_scaled_font_set_error (&scaled_font->base, status);
+	return NULL;
+    }
 
     /* NOTE: We deliberately release the unscaled font's mutex here,
      * so that we are not holding a lock across two separate calls to
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 2391457..0b19c8b 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -397,15 +397,18 @@ _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font)
 					       max_glyphs_cached_per_font);
 }
 
-void
+cairo_status_t
 _cairo_scaled_font_set_metrics (cairo_scaled_font_t	    *scaled_font,
 				cairo_font_extents_t	    *fs_metrics)
 {
     double  font_scale_x, font_scale_y;
+    cairo_status_t status;
 
-    _cairo_matrix_compute_scale_factors (&scaled_font->font_matrix,
-					 &font_scale_x, &font_scale_y,
-					 /* XXX */ 1);
+    status = _cairo_matrix_compute_scale_factors (&scaled_font->font_matrix,
+					          &font_scale_x, &font_scale_y,
+					          /* XXX */ 1);
+    if (status)
+	return status;
 
     /*
      * The font responded in unscaled units, scale by the font
@@ -417,6 +420,8 @@ _cairo_scaled_font_set_metrics (cairo_scaled_font_t	    *scaled_font,
     scaled_font->extents.height = fs_metrics->height * font_scale_y;
     scaled_font->extents.max_x_advance = fs_metrics->max_x_advance * font_scale_x;
     scaled_font->extents.max_y_advance = fs_metrics->max_y_advance * font_scale_y;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 void
diff --git a/src/cairoint.h b/src/cairoint.h
index cef52fc..cbb0b74 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1744,7 +1744,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
 			 const cairo_font_options_t	   *options,
 			 const cairo_scaled_font_backend_t *backend);
 
-cairo_private void
+cairo_private cairo_status_t
 _cairo_scaled_font_set_metrics (cairo_scaled_font_t	    *scaled_font,
 				cairo_font_extents_t	    *fs_metrics);
 
-- 
1.4.4.2

-------------- next part --------------
>From 1f7156528afd9545b42b05742b684817fe786c37 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 15:43:37 +0100
Subject: [PATCH] Propagate some error returns up through the svg call stack.

---
 src/cairo-svg-surface.c |   56 +++++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 1c885d1..7d217a9 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -707,14 +707,21 @@ _cairo_svg_document_emit_font_subset (cairo_scaled_font_subset_t	*font_subset,
     }
 }
 
-static void
+static cairo_status_t
 _cairo_svg_document_emit_font_subsets (cairo_svg_document_t *document)
 {
-    _cairo_scaled_font_subsets_foreach_scaled (document->font_subsets,
-                                               _cairo_svg_document_emit_font_subset,
-                                               document);
+    cairo_status_t status;
+
+    status = _cairo_scaled_font_subsets_foreach_scaled (document->font_subsets,
+                                                        _cairo_svg_document_emit_font_subset,
+                                                        document);
+    if (status)
+	return status;
+
     _cairo_scaled_font_subsets_destroy (document->font_subsets);
     document->font_subsets = NULL;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_bool_t cairo_svg_force_fallbacks = FALSE;
@@ -1162,7 +1169,7 @@ _cairo_svg_surface_emit_operator (cairo_output_stream_t *output,
 	_cairo_output_stream_printf (output, "comp-op: %s; ", op_str[op]);
 }
 
-static void
+static cairo_status_t
 _cairo_svg_surface_emit_solid_pattern (cairo_svg_surface_t	    *surface,
 		    cairo_solid_pattern_t   *pattern,
 		    cairo_output_stream_t   *style,
@@ -1176,9 +1183,11 @@ _cairo_svg_surface_emit_solid_pattern (cairo_svg_surface_t	    *surface,
 				 pattern->color.green * 100.0,
 				 pattern->color.blue * 100.0,
 				 pattern->color.alpha);
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 _cairo_svg_surface_emit_surface_pattern (cairo_svg_surface_t	*surface,
 		      cairo_surface_pattern_t	*pattern,
 		      cairo_output_stream_t     *style,
@@ -1195,6 +1204,8 @@ _cairo_svg_surface_emit_surface_pattern (cairo_svg_surface_t	*surface,
 				 "%s: url(#pattern%d);",
 				 is_stroke ? "color" : "fill",
 				 pattern_id);
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -1376,7 +1387,7 @@ _cairo_svg_surface_emit_pattern_extend (cairo_output_stream_t *output,
     }
 }
 
-static void
+static cairo_status_t
 _cairo_svg_surface_emit_linear_pattern (cairo_svg_surface_t    *surface,
 		     cairo_linear_pattern_t *pattern,
 		     cairo_output_stream_t  *style,
@@ -1418,9 +1429,11 @@ _cairo_svg_surface_emit_linear_pattern (cairo_svg_surface_t    *surface,
 				 document->linear_pattern_id);
 
     document->linear_pattern_id++;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
 		     cairo_radial_pattern_t *pattern,
 		     cairo_output_stream_t  *style,
@@ -1432,6 +1445,7 @@ _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
     double x0, y0, x1, y1, r0, r1;
     double fx, fy;
     cairo_bool_t reverse_stops;
+    cairo_status_t status;
     pixman_circle_t *c0, *c1;
 
     extend = pattern->base.base.extend;
@@ -1454,7 +1468,9 @@ _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
     r1 = _cairo_fixed_to_double (c1->radius);
 
     p2u = pattern->base.base.matrix;
-    cairo_matrix_invert (&p2u);
+    status = cairo_matrix_invert (&p2u);
+    if (status)
+	return status;
 
     if (pattern->gradient.c1.radius == pattern->gradient.c2.radius) {
 	_cairo_output_stream_printf (document->xml_node_defs,
@@ -1585,29 +1601,28 @@ _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
 				 document->radial_pattern_id);
 
     document->radial_pattern_id++;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 _cairo_svg_surface_emit_pattern (cairo_svg_surface_t *surface, cairo_pattern_t *pattern,
 	      cairo_output_stream_t *output, cairo_bool_t is_stroke)
 {
     switch (pattern->type) {
     case CAIRO_PATTERN_TYPE_SOLID:
-	_cairo_svg_surface_emit_solid_pattern (surface, (cairo_solid_pattern_t *) pattern, output, is_stroke);
-	break;
+	return _cairo_svg_surface_emit_solid_pattern (surface, (cairo_solid_pattern_t *) pattern, output, is_stroke);
 
     case CAIRO_PATTERN_TYPE_SURFACE:
-	_cairo_svg_surface_emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern, output, is_stroke);
-	break;
+	return _cairo_svg_surface_emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern, output, is_stroke);
 
     case CAIRO_PATTERN_TYPE_LINEAR:
-	_cairo_svg_surface_emit_linear_pattern (surface, (cairo_linear_pattern_t *) pattern, output, is_stroke);
-	break;
+	return _cairo_svg_surface_emit_linear_pattern (surface, (cairo_linear_pattern_t *) pattern, output, is_stroke);
 
     case CAIRO_PATTERN_TYPE_RADIAL:
-	_cairo_svg_surface_emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern, output, is_stroke);
-	break;
+	return _cairo_svg_surface_emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern, output, is_stroke);
     }
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_int_status_t
@@ -2127,7 +2142,10 @@ _cairo_svg_document_finish (cairo_svg_document_t *document)
 				 document->width, document->height,
 				 _cairo_svg_internal_version_strings [document->svg_version]);
 
-    _cairo_svg_document_emit_font_subsets (document);
+    status = _cairo_svg_document_emit_font_subsets (document);
+    if (status)
+	return status;
+
     if (_cairo_memory_stream_length (document->xml_node_glyphs) > 0 ||
 	_cairo_memory_stream_length (document->xml_node_defs) > 0) {
 	_cairo_output_stream_printf (output, "<defs>\n");
-- 
1.4.4.2

-------------- next part --------------
>From df63ea77e3d80f550b6a461dc2401816240f5b8f Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 15:50:12 +0100
Subject: [PATCH] Propagate one error return through pdf.

---
 src/cairo-pdf-surface.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 67cfbc6..2118973 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1192,6 +1192,7 @@ _cairo_pdf_surface_emit_linear_pattern (cairo_pdf_surface_t *surface, cairo_line
     cairo_pdf_resource_t function, pattern_resource, alpha;
     double x0, y0, x1, y1;
     cairo_matrix_t p2u;
+    cairo_status_t status;
 
     _cairo_pdf_surface_pause_content_stream (surface);
 
@@ -1200,7 +1201,9 @@ _cairo_pdf_surface_emit_linear_pattern (cairo_pdf_surface_t *surface, cairo_line
 	return CAIRO_STATUS_NO_MEMORY;
 
     p2u = pattern->base.base.matrix;
-    cairo_matrix_invert (&p2u);
+    status = cairo_matrix_invert (&p2u);
+    if (status)
+	return status;
 
     x0 = _cairo_fixed_to_double (pattern->gradient.p1.x);
     y0 = _cairo_fixed_to_double (pattern->gradient.p1.y);
-- 
1.4.4.2

-------------- next part --------------
>From 003eefe74656083d2641e3edf5fdad877ca5a560 Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 28 Mar 2007 15:55:06 +0100
Subject: [PATCH] Propagate status returns through type1.

---
 src/cairo-type1-fallback.c |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index eef0d73..b88930a 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -63,6 +63,12 @@ typedef struct _cairo_type1_font {
     int hex_column;
 } cairo_type1_font_t;
 
+cairo_static cairo_status_t
+cairo_type1_font_write_header (cairo_type1_font_t *font,
+                               const char         *name);
+cairo_static cairo_status_t
+cairo_type1_font_destroy (cairo_type1_font_t *font);
+
 static cairo_status_t
 cairo_type1_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
                          cairo_type1_font_t         **subset_return,
@@ -464,18 +470,21 @@ fail:
     return status;
 }
 
-static void
+static cairo_status_t
 cairo_type1_font_write_header (cairo_type1_font_t *font,
                                const char         *name)
 {
     cairo_matrix_t matrix;
+    cairo_status_t status;
     unsigned int i;
     const char spaces[50] = "                                                  ";
 
     matrix = font->type1_scaled_font->scale;
     matrix.xy = -matrix.xy;
     matrix.yy = -matrix.yy;
-    cairo_matrix_invert (&matrix);
+    status = cairo_matrix_invert (&matrix);
+    if (status)
+	return status;
 
     _cairo_output_stream_printf (font->output,
                                  "%%!FontType1-1.1 %s 1.0\n"
@@ -512,6 +521,8 @@ cairo_type1_font_write_header (cairo_type1_font_t *font,
                                  "readonly def\n"
                                  "currentdict end\n"
                                  "currentfile eexec\n");
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -635,7 +646,9 @@ cairo_type1_font_write (cairo_type1_font_t *font,
 {
     cairo_int_status_t status;
 
-    cairo_type1_font_write_header (font, name);
+    status = cairo_type1_font_write_header (font, name);
+    if (status)
+	return status;
     font->header_size = _cairo_output_stream_get_position (font->output);
 
     status = cairo_type1_font_write_private_dict (font, name);
@@ -673,14 +686,18 @@ cairo_type1_font_generate (cairo_type1_font_t *font, const char *name)
     return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 cairo_type1_font_destroy (cairo_type1_font_t *font)
 {
+    cairo_status_t status;
+
     free (font->widths);
     cairo_scaled_font_destroy (font->type1_scaled_font);
     _cairo_array_fini (&font->contents);
-    _cairo_output_stream_destroy (font->output);
+    status = _cairo_output_stream_destroy (font->output);
     free (font);
+
+    return status;
 }
 
 static cairo_status_t
@@ -746,14 +763,14 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t	*type1_subset,
     type1_subset->data_length = font->data_size;
     type1_subset->trailer_length = font->trailer_size;
 
-    cairo_type1_font_destroy (font);
-    return CAIRO_STATUS_SUCCESS;
+    return cairo_type1_font_destroy (font);
 
  fail3:
     free (type1_subset->widths);
  fail2:
     free (type1_subset->base_font);
  fail1:
+    /* status is already set, ignore further errors */
     cairo_type1_font_destroy (font);
 
     return status;
-- 
1.4.4.2



More information about the cairo mailing list