[cairo-commit] src/cairo-gstate.c src/cairo-scaled-font.c src/cairo-scaled-font-subsets.c src/cairo-type1-fallback.c

Chris Wilson ickle at kemper.freedesktop.org
Thu May 10 09:18:28 PDT 2007


 src/cairo-gstate.c              |    7 +++----
 src/cairo-scaled-font-subsets.c |    2 ++
 src/cairo-scaled-font.c         |   10 ++++++++--
 src/cairo-type1-fallback.c      |    2 +-
 4 files changed, 14 insertions(+), 7 deletions(-)

New commits:
diff-tree ab6a767cf476c98b466c62dd410d0f61f8dd6bbb (from aec92188f1cf4ca34e890b0a4266425532f669d4)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu May 10 17:17:30 2007 +0100

    [cairo-scaled-font] Check for allocation failure.
    
    cairo_scaled_font_create() returns a nil object on failure whereas a few
    callers were checking for NULL.
    
    Secondly review the public entry points for cairo_scaled_font_*() to
    ensure that all check that they will not attempt to overwrite the
    read-only nil object.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 3787aeb..ad560cd 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1464,11 +1464,10 @@ _cairo_gstate_ensure_scaled_font (cairo_
 						    &gstate->font_matrix,
 						    &gstate->ctm,
 						    &options);
-    if (gstate->scaled_font == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
 
-    if (cairo_scaled_font_status (gstate->scaled_font))
-	return cairo_scaled_font_status (gstate->scaled_font);
+    status = cairo_scaled_font_status (gstate->scaled_font);
+    if (status)
+	return status;
 
     return CAIRO_STATUS_SUCCESS;
 }
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index fa5a8b4..3489ee6 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -531,6 +531,8 @@ _cairo_scaled_font_subsets_map_glyph (ca
                                                       &identity,
                                                       &identity,
                                                       &font_options);
+	    if (unscaled_font->status)
+		return unscaled_font->status;
 
             subset_glyph->is_scaled = FALSE;
             type1_font = FALSE;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index d6726b3..40ff698 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -135,6 +135,9 @@ _cairo_scaled_font_set_error (cairo_scal
 cairo_font_type_t
 cairo_scaled_font_get_type (cairo_scaled_font_t *scaled_font)
 {
+    if (scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
+	return CAIRO_FONT_TYPE_TOY;
+
     return scaled_font->backend->type;
 }
 
@@ -770,10 +773,13 @@ cairo_scaled_font_text_extents (cairo_sc
 				const char            *utf8,
 				cairo_text_extents_t  *extents)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status;
     cairo_glyph_t *glyphs;
     int num_glyphs;
 
+    if (scaled_font->status)
+	return;
+
     status = _cairo_scaled_font_text_to_glyphs (scaled_font, 0., 0., utf8, &glyphs, &num_glyphs);
     if (status) {
         _cairo_scaled_font_set_error (scaled_font, status);
@@ -807,7 +813,7 @@ cairo_scaled_font_glyph_extents (cairo_s
 				 int                    num_glyphs,
 				 cairo_text_extents_t  *extents)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status;
     int i;
     double min_x = 0.0, min_y = 0.0, max_x = 0.0, max_y = 0.0;
     cairo_bool_t visible = FALSE;
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 3a0bd12..3872777 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -106,7 +106,7 @@ cairo_type1_font_create (cairo_scaled_fo
 							&font_matrix,
 							&ctm,
 							&font_options);
-    if (font->type1_scaled_font == NULL)
+    if (font->type1_scaled_font->status)
         goto fail;
 
     _cairo_array_init (&font->contents, sizeof (unsigned char));


More information about the cairo-commit mailing list