diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-01-29 09:50:38 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-01-29 10:10:41 +0000 |
commit | 8388af137841679b7c510980daf3cec1427b6e6b (patch) | |
tree | 2abd6336f5c3944b0d346c64f2fdaa2c6a78cb68 /test/create-from-png-stream.c | |
parent | 3752f690b467432ab5b1058d450cb79d719a794a (diff) | |
download | cairo-8388af137841679b7c510980daf3cec1427b6e6b.tar.gz |
[test] Trivial fixes for error paths.
Kill a few leaks along error paths in the test code.
Diffstat (limited to 'test/create-from-png-stream.c')
-rw-r--r-- | test/create-from-png-stream.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/test/create-from-png-stream.c b/test/create-from-png-stream.c index 3d1957dba..a5c539525 100644 --- a/test/create-from-png-stream.c +++ b/test/create-from-png-stream.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <stdio.h> +#include <errno.h> #define WIDTH 2 #define HEIGHT 2 @@ -51,15 +52,24 @@ draw (cairo_t *cr, int width, int height) char *filename; FILE *file; cairo_surface_t *surface; + cairo_status_t status; xasprintf (&filename, "%s/%s", ctx->srcdir, "create-from-png-stream.ref.png"); file = fopen (filename, "rb"); if (file == NULL) { - cairo_test_log (ctx, "Error: failed to open file: %s\n", filename); + cairo_test_status_t ret; + + ret = CAIRO_TEST_FAILURE; + if (errno == ENOMEM) + ret = cairo_test_status_from_status (ctx, CAIRO_STATUS_NO_MEMORY); + + if (ret != CAIRO_TEST_NO_MEMORY) + cairo_test_log (ctx, "Error: failed to open file: %s\n", filename); + free (filename); - return CAIRO_TEST_FAILURE; + return ret; } surface = cairo_image_surface_create_from_png_stream (read_png_from_file, @@ -67,13 +77,23 @@ draw (cairo_t *cr, int width, int height) fclose (file); - if (cairo_surface_status (surface)) { - cairo_test_log (ctx, - "Error: failed to create surface from PNG: %s - %s\n", - filename, - cairo_status_to_string (cairo_surface_status (surface))); + status = cairo_surface_status (surface); + if (status) { + cairo_test_status_t ret; + + cairo_surface_destroy (surface); + + ret = cairo_test_status_from_status (ctx, status); + if (ret != CAIRO_TEST_NO_MEMORY) { + cairo_test_log (ctx, + "Error: failed to create surface from PNG: %s - %s\n", + filename, + cairo_status_to_string (status)); + } + free (filename); - return CAIRO_TEST_FAILURE; + + return ret; } free (filename); |