Submitted by Massimo
Assigned to Uli Schlachter
( cd test; DISPLAY=:2 CAIRO_TEST_TARGET=xcb valgrind --leak-check=full .libs/cairo-test-suite -f random-clip )
==475== 6,160 (144 direct, 6,016 indirect) bytes in 2 blocks are definitely lost in loss record 10 of 10 ==475== at 0x4A06C10: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==475== by 0x4C353FA: _cairo_clip_create (cairo/src/cairo-clip.c:111) ==475== by 0x4C35649: _cairo_clip_copy (cairo/src/cairo-clip.c:151) ==475== by 0x4C36F73: _cairo_clip_copy_intersect_rectangle (cairo/src/cairo-clip-inline.h:58) ==475== by 0x4C36F73: _cairo_clip_reduce_to_rectangle (cairo/src/cairo-clip-boxes.c:559) ==475== by 0x4C381E2: _cairo_composite_rectangles_intersect_mask_extents (cairo/src/cairo-composite-rectangles.c:292) ==475== by 0x4CBB06A: trim_extents_to_traps (cairo/src/cairo-xcb-surface-render.c:2859) ==475== by 0x4CBB06A: _composite_polygon (cairo/src/cairo-xcb-surface-render.c:3065) ==475== by 0x4CBA529: _clip_and_composite_boxes (cairo/src/cairo-xcb-surface-render.c:3141) ==475== by 0x4CBC5ED: _cairo_xcb_render_compositor_paint (cairo/src/cairo-xcb-surface-render.c:3556) ==475== by 0x4C38CE8: _cairo_compositor_paint (cairo/src/cairo-compositor.c:65) ==475== by 0x4C7EB40: _cairo_surface_paint (cairo/src/cairo-surface.c:2117) ==475== by 0x4C4062E: _cairo_gstate_paint (cairo/src/cairo-gstate.c:1067) ==475== by 0x4C33BC4: cairo_paint (cairo/src/cairo.c:2003) ==475== by 0x439B3C: draw (cairo/test/random-clips.c:221) ==475== by 0x40E5F1: cairo_test_for_target (cairo/test/cairo-test.c:929) ==475== by 0x40E5F1: _cairo_test_context_run_for_target (cairo/test/cairo-test.c:1532) ==475== by 0x40BA53: _cairo_test_runner_draw (cairo/test/cairo-test-runner.c:255) ==475== by 0x40BA53: main (cairo/test/cairo-test-runner.c:937)
A copy (intersected with 'boxes') of extents->clip is assigned to extents->clip which is passed to '_composite_polygon', when '_composite_polygon' changes again extents->clip, it destroys the previous copy and places there a new one (simplified or whatever), this new one is leaked because at line 3147 rather then assign it to 'clip' which will be destroyed few lines later, NULL is assigned to 'clip' and the next line extents->clip is overwritten with the original.
My suggestion here is to assign extents->clip to 'clip' at line 3147.