From a845ebe32d68a4701fd0645c576a2dc65c82ca8f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 20 May 2012 12:11:27 +0100 Subject: [PATCH] test: Fix leak from xcb-snapshort-assert ==12598== 1,344 (768 direct, 576 indirect) bytes in 2 blocks are definitely lost in loss record 512 of 519 ==12598== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==12598== by 0x4C76501: _cairo_image_surface_create_for_pixman_image (cairo-image-surface.c:176) ==12598== by 0x4C76953: _cairo_image_surface_create_with_pixman_format (cairo-image-surface.c:345) ==12598== by 0x44CFAC: draw (xcb-snapshot-assert.c:36) ==12598== by 0x40E14C: cairo_test_for_target (cairo-test.c:923) ==12598== by 0x40EEA7: _cairo_test_context_run_for_target (cairo-test.c:1545) ==12598== by 0x40BD53: main (cairo-test-runner.c:254) Signed-off-by: Chris Wilson --- test/xcb-snapshot-assert.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/xcb-snapshot-assert.c b/test/xcb-snapshot-assert.c index e1ddb73c9..a67447678 100644 --- a/test/xcb-snapshot-assert.c +++ b/test/xcb-snapshot-assert.c @@ -36,8 +36,12 @@ create_image (int width, int height) surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); /* Paint something random to the image */ cr = cairo_create (surface); + cairo_surface_destroy (surface); + cairo_set_source_rgb (cr, 0, 1, 1); cairo_paint (cr); + + surface = cairo_surface_reference (cairo_get_target (cr)); cairo_destroy (cr); return surface; @@ -46,8 +50,12 @@ create_image (int width, int height) static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + cairo_surface_t *image; + /* Image has to have same geometry as xcb surface to be added as a snapshot */ - cairo_set_source_surface (cr, create_image (width, height), 0, 0); + image = create_image (width, height); + cairo_set_source_surface (cr, image, 0, 0); + cairo_surface_destroy (image); /* This attaches the tested xcb surface as a snapshot */ cairo_paint (cr);