[cairo-commit] src/cairo-surface.c

Carl Worth cworth at kemper.freedesktop.org
Mon Mar 19 16:51:35 PDT 2007


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

New commits:
diff-tree 725a4de42dfaf0d9d98447c9fbefed99fbf99ac1 (from eb472a9d9cbaea754907a261b459693b9c27ac79)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Mar 19 16:50:55 2007 -0700

    Propagate a nil surface out of _cairo_surface_create_similar_scratch
    
    We detect an error in the surface before calling into private surface-modifying
    functions, (such as _cairo_surface_set_font_options), that don't have the
    nil-surface protection of public functions.
    
    This should fix the problem reported (again) in this bug report:
    
    	cairo crashes in cairo_create_simular if nil surface returned by other->backend->create_similar
    	https://bugs.freedesktop.org/show_bug.cgi?id=9844
    
    Though I haven't succeeded in replicating the bug yet, (perhaps a system
    difference in allowing writes to read-only memory or not, or something
    like that).

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 516f30d..92efa00 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -234,6 +234,10 @@ _cairo_surface_create_similar_scratch (c
     if (surface == NULL)
 	surface = cairo_image_surface_create (format, width, height);
 
+    /* If any error occurred, then return the nil surface we received. */
+    if (surface->status)
+	return surface;
+
     cairo_surface_get_font_options (other, &options);
     _cairo_surface_set_font_options (surface, &options);
 


More information about the cairo-commit mailing list