[cairo-commit] 6 commits - boilerplate/cairo-boilerplate.c boilerplate/cairo-boilerplate-ps.c src/cairo-paginated-surface.c src/test-fallback-surface.c test/cairo-test.c test/nil-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Tue May 8 08:48:50 PDT 2007


 boilerplate/cairo-boilerplate-ps.c |    2 ++
 boilerplate/cairo-boilerplate.c    |    3 +++
 src/cairo-paginated-surface.c      |   10 ++++++++--
 src/test-fallback-surface.c        |    1 +
 test/cairo-test.c                  |    4 +++-
 test/nil-surface.c                 |    5 +++++
 6 files changed, 22 insertions(+), 3 deletions(-)

New commits:
diff-tree aad66d05fd0f310564e80c9ff59526028871751c (from e3acacc096d7db947e7c8f2167a6d97f04c403b1)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 8 16:40:24 2007 +0100

    [test/nil-surface] Destroy the auxiliary context on failure paths.
    
    Just to be tidy, and aim to be valgrind-clean.

diff --git a/test/nil-surface.c b/test/nil-surface.c
index bbabfd9..91f1aa6 100644
--- a/test/nil-surface.c
+++ b/test/nil-surface.c
@@ -74,6 +74,7 @@ draw (cairo_t *cr, int width, int height
 	cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
 			cairo_status_to_string (cairo_status (cr2)),
 			cairo_status_to_string (CAIRO_STATUS_FILE_NOT_FOUND));
+	cairo_destroy (cr2);
 	return CAIRO_TEST_FAILURE;
     }
 
@@ -98,6 +99,7 @@ draw (cairo_t *cr, int width, int height
 	cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
 			cairo_status_to_string (cairo_status (cr2)),
 			cairo_status_to_string (CAIRO_STATUS_NULL_POINTER));
+	cairo_destroy (cr2);
 	return CAIRO_TEST_FAILURE;
     }
 
@@ -128,6 +130,7 @@ draw (cairo_t *cr, int width, int height
 	cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
 			cairo_status_to_string (cairo_status (cr2)),
 			cairo_status_to_string (CAIRO_STATUS_INVALID_RESTORE));
+	cairo_destroy (cr2);
 	return CAIRO_TEST_FAILURE;
     }
 
@@ -145,12 +148,14 @@ draw (cairo_t *cr, int width, int height
 	cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
 			cairo_status_to_string (cairo_status (cr2)),
 			cairo_status_to_string (CAIRO_STATUS_NULL_POINTER));
+	cairo_destroy (cr2);
 	return CAIRO_TEST_FAILURE;
     }
 
     /* Test that get_target returns something valid */
     if (cairo_get_target (cr2) == NULL) {
 	cairo_test_log ("Error: cairo_get_target() returned NULL\n");
+	cairo_destroy (cr2);
 	return CAIRO_TEST_FAILURE;
     }
 
diff-tree e3acacc096d7db947e7c8f2167a6d97f04c403b1 (from efd212bfa25cb44b9499b89f93aa7167a9544ccb)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 8 16:35:14 2007 +0100

    [cairo-boilerplate-ps] Destroy the target on creation failure
    
    Remember to destroy the ptc->target as well as the ordinary surface, if
    we need to.

diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index 0e7a764..7d5ea7d 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -87,6 +87,8 @@ _cairo_boilerplate_ps_create_surface (co
 				     ptc,
 				     NULL) != CAIRO_STATUS_SUCCESS) {
 	cairo_surface_destroy (surface);
+	if (ptc->target != NULL)
+	    cairo_surface_destroy (ptc->target);
 	free (ptc->filename);
 	free (ptc);
 	return NULL;
diff-tree efd212bfa25cb44b9499b89f93aa7167a9544ccb (from b85920684f8feaba8d2d5b0262c60b4960c223b8)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 8 16:23:07 2007 +0100

    [cairo-boilerplate] Protect against the nil cairo_scaled_font_t
    
    Beware the NULL pointer deference when trying to adjust the max glyph
    cache size...

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 5c86a1d..093a55a 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -443,5 +443,8 @@ void
 cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font,
 						     int max_glyphs)
 {
+    if (cairo_scaled_font_status (scaled_font))
+	return;
+
     scaled_font->glyphs->max_size = max_glyphs;
 }
diff-tree b85920684f8feaba8d2d5b0262c60b4960c223b8 (from 0bf3ffacda5dbfc4fd8a5a0d5fd37d9630f5bcdb)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 8 14:01:00 2007 +0100

    [cairo-test] Destroy the check image on failure
    
    If drawing the checker pattern should fail, we need to free the
    resources allocated locally.

diff --git a/test/cairo-test.c b/test/cairo-test.c
index 7bc5dd6..3a92050 100755
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -680,8 +680,10 @@ cairo_test_paint_checkered (cairo_t *cr)
 
     check = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 12, 12);
     status = _draw_check (check, 12, 12);
-    if (status)
+    if (status) {
+	cairo_surface_destroy (check);
 	return status;
+    }
 
     cairo_save (cr);
     cairo_set_source_surface (cr, check, 0, 0);
diff-tree 0bf3ffacda5dbfc4fd8a5a0d5fd37d9630f5bcdb (from eac18d44c7559fe393abf6706b52e5a8edbfd5e9)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 8 13:55:04 2007 +0100

    [test-fallback-surface] Destroy the backing image on malloc failure.
    
    Ensure we free all local resource should we encounter an allocation
    failure during _cairo_test_fallback_surface_create().

diff --git a/src/test-fallback-surface.c b/src/test-fallback-surface.c
index 0b06dc1..b2fa03e 100644
--- a/src/test-fallback-surface.c
+++ b/src/test-fallback-surface.c
@@ -80,6 +80,7 @@ _cairo_test_fallback_surface_create (cai
 
     surface = malloc (sizeof (test_fallback_surface_t));
     if (surface == NULL) {
+	cairo_surface_destroy (backing);
 	_cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_surface_t*) &_cairo_surface_nil;
     }
diff-tree eac18d44c7559fe393abf6706b52e5a8edbfd5e9 (from 0d8a1540ec53ecc309a10e77ea7788fcd16d8345)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 8 12:46:42 2007 +0100

    [cairo-paginated-surface] Propagate malloc failure
    
    Check for an allocation failure during _cairo_analysis_surface_create()
    and propagate to caller - where we discover that the callers themselves
    missed the status checks...

diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index c9584b6..1fa0e7b 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -214,6 +214,8 @@ _paint_page (cairo_paginated_surface_t *
 
     analysis = _cairo_analysis_surface_create (surface->target,
 					       surface->width, surface->height);
+    if (analysis == NULL)
+	return CAIRO_STATUS_NO_MEMORY;
 
     surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
     status = _cairo_meta_surface_replay (surface->meta, analysis);
@@ -281,7 +283,9 @@ _cairo_paginated_surface_copy_page (void
     if (status)
 	return status;
 
-    _paint_page (surface);
+    status = _paint_page (surface);
+    if (status)
+	return status;
 
     surface->page_num++;
 
@@ -306,7 +310,9 @@ _cairo_paginated_surface_show_page (void
     if (status)
 	return status;
 
-    _paint_page (surface);
+    status = _paint_page (surface);
+    if (status)
+	return status;
 
     status = _cairo_surface_show_page (surface->target);
     if (status)


More information about the cairo-commit mailing list