summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-05-20 12:11:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-05-20 12:12:03 +0100
commita845ebe32d68a4701fd0645c576a2dc65c82ca8f (patch)
tree9d1b4c1b53e569108e4bb5323f029d9b537cec4b
parent2879e656b9b9283308ed4eaf3ad820460ac1df8b (diff)
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 <chris@chris-wilson.co.uk>
-rw-r--r--test/xcb-snapshot-assert.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/xcb-snapshot-assert.c b/test/xcb-snapshot-assert.c
index e1ddb73c..a6744767 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);