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>
This commit is contained in:
Chris Wilson 2012-05-20 12:11:27 +01:00
parent 2879e656b9
commit a845ebe32d

View file

@ -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);