Commit e3eaccb9 authored by Uli Schlachter's avatar Uli Schlachter
Browse files

boilerplate-xcb: Avoid leaks on error

Before this commit, running the test suite against a non-existing
display under valgrind resulted in:

$ ( cd test; DISPLAY=:2 CAIRO_TEST_TARGET=xcb valgrind --leak-check=full .libs/cairo-test-suite -f random-clip )
==47359== 64 bytes in 2 blocks are definitely lost in loss record 1 of 7
==47359==    at 0x483AB65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/
==47359==    by 0x18A272: cairo_boilerplate_xcalloc (cairo-boilerplate-system.c:65)
==47359==    by 0x18D652: _cairo_boilerplate_xcb_create_surface (cairo-boilerplate-xcb.c:269)
==47359==    by 0x12906F: cairo_test_for_target (cairo-test.c:819)
==47359==    by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
==47359==    by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
==47359==    by 0x126921: main (cairo-test-runner.c:932)

This commit fixes that by freeing the allocated memory in the error
Signed-off-by: Uli Schlachter's avatarUli Schlachter <>
parent f7054c89
......@@ -276,6 +276,7 @@ _cairo_boilerplate_xcb_create_surface (const char *name,
xtc->c = c = xcb_connect(NULL,NULL);
if (c == NULL || xcb_connection_has_error(c)) {
free (xtc);
free (info);
return NULL;
......@@ -309,12 +310,17 @@ _cairo_boilerplate_xcb_create_surface (const char *name,
if (xcb_request_check (c, cookie) != NULL) {
xcb_disconnect (c);
free (xtc);
free (info);
return NULL;
info->formats = xcb_render_query_pict_formats_reply (c, formats_cookie, 0);
if (info->formats == NULL)
if (info->formats == NULL) {
xcb_disconnect (c);
free (xtc);
free (info);
return NULL;
for (i = xcb_render_query_pict_formats_formats_iterator (info->formats);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment