[cairo-commit] 3 commits - boilerplate/cairo-boilerplate-xcb.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Dec 25 14:43:54 UTC 2020
boilerplate/cairo-boilerplate-xcb.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
New commits:
commit 979382dd302bbab73d8c81740ddd72afc31a8ea8
Merge: c7b6c073e 2ceb279d7
Author: Uli Schlachter <psychon at znc.in>
Date: Fri Dec 25 14:43:52 2020 +0000
Merge branch 'boilerplate-leak' into 'master'
boilerplate-xcb: Avoid leaks on error
See merge request cairo/cairo!82
commit 2ceb279d704840dacf6880b5bf2e168ede16097a
Author: Uli Schlachter <psychon at znc.in>
Date: Sat Dec 5 08:08:14 2020 +0100
boilerplate-xcb: Avoid leaks on success
This gets rid of the following two leaks reported by valgrind when successfully
running a test with CAIRO_TEST_TARGET=xcb:
8,000 bytes in 2 blocks are definitely lost in loss record 9 of 10
at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4B7E135: read_packet (xcb_in.c:259)
by 0x4B7E135: _xcb_in_read (xcb_in.c:1031)
by 0x4B7BF8E: _xcb_conn_wait (xcb_conn.c:516)
by 0x4B7D6AE: wait_for_reply (xcb_in.c:516)
by 0x4B7D8C8: xcb_request_check (xcb_in.c:745)
by 0x18D747: _cairo_boilerplate_xcb_create_surface (cairo-boilerplate-xcb.c:310)
by 0x12906F: cairo_test_for_target (cairo-test.c:819)
by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
by 0x126921: main (cairo-test-runner.c:932)
8,000 bytes in 2 blocks are definitely lost in loss record 10 of 10
at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4B7E135: read_packet (xcb_in.c:259)
by 0x4B7E135: _xcb_in_read (xcb_in.c:1031)
by 0x4B7BF8E: _xcb_conn_wait (xcb_conn.c:516)
by 0x4B7D6AE: wait_for_reply (xcb_in.c:516)
by 0x4B7D7C0: xcb_wait_for_reply (xcb_in.c:546)
by 0x18D45D: find_depth (cairo-boilerplate-xcb.c:154)
by 0x18D45D: _cairo_boilerplate_xcb_create_render_0_0 (cairo-boilerplate-xcb.c:621)
by 0x12906F: cairo_test_for_target (cairo-test.c:819)
by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
by 0x126921: main (cairo-test-runner.c:932)
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index e301d1299..98b39ec58 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -174,6 +174,7 @@ find_depth (xcb_connection_t *connection,
}
static const cairo_user_data_key_t key;
+static const cairo_user_data_key_t key2;
struct similar {
xcb_connection_t *connection;
@@ -365,6 +366,7 @@ _cairo_boilerplate_xcb_create_surface (const char *name,
render_format,
width, height);
cairo_device_set_user_data (cairo_surface_get_device (surface), &key, info, free);
+ cairo_device_set_user_data (cairo_surface_get_device (surface), &key2, info->formats, free);
if (mode != CAIRO_BOILERPLATE_MODE_PERF)
_cairo_boilerplate_xcb_setup_test_surface(surface);
@@ -629,8 +631,8 @@ _cairo_boilerplate_xcb_create_render_0_0 (const char *name,
xtc->drawable,
render_format,
width, height);
+ free (formats);
if (cairo_surface_status (surface)) {
- free (formats);
xcb_disconnect (c);
free (xtc);
return surface;
commit e3eaccb939836386aa5f5895eea0da3e9863826c
Author: Uli Schlachter <psychon at znc.in>
Date: Sat Dec 5 07:46:41 2020 +0100
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/vgpreload_memcheck-amd64-linux.so)
==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
path.
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index cc9b422e9..e301d1299 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -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);
i.rem;
More information about the cairo-commit
mailing list