mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
comp: Don't leak xcb replies.
According the XCB documentation the reply structs must be freed. I found this when running a minimal example related to the direct mode code in valgrind.
This commit is contained in:
parent
a8a4d8c3dd
commit
20f281631b
|
@ -762,6 +762,8 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w)
|
||||||
COMP_DEBUG(w->base.c, "RandR version below 1.6.");
|
COMP_DEBUG(w->base.c, "RandR version below 1.6.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(version_reply);
|
||||||
|
|
||||||
xcb_generic_error_t *error = nullptr;
|
xcb_generic_error_t *error = nullptr;
|
||||||
xcb_intern_atom_cookie_t non_desktop_cookie = xcb_intern_atom(
|
xcb_intern_atom_cookie_t non_desktop_cookie = xcb_intern_atom(
|
||||||
w->connection, 1, strlen("non-desktop"), "non-desktop");
|
w->connection, 1, strlen("non-desktop"), "non-desktop");
|
||||||
|
@ -811,6 +813,7 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w)
|
||||||
// Only outputs with an available mode should be used
|
// Only outputs with an available mode should be used
|
||||||
// (it is possible to see 'ghost' outputs with non-desktop=1).
|
// (it is possible to see 'ghost' outputs with non-desktop=1).
|
||||||
if (output_reply->num_modes == 0) {
|
if (output_reply->num_modes == 0) {
|
||||||
|
free(output_reply);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,12 +839,14 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w)
|
||||||
"returned error %d",
|
"returned error %d",
|
||||||
error->error_code);
|
error->error_code);
|
||||||
free(name_str);
|
free(name_str);
|
||||||
|
free(prop_reply);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop_reply == nullptr) {
|
if (prop_reply == nullptr) {
|
||||||
COMP_ERROR(w->base.c, "property reply == nullptr");
|
COMP_ERROR(w->base.c, "property reply == nullptr");
|
||||||
free(name_str);
|
free(name_str);
|
||||||
|
free(prop_reply);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,6 +854,7 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w)
|
||||||
prop_reply->num_items != 1 || prop_reply->format != 32) {
|
prop_reply->num_items != 1 || prop_reply->format != 32) {
|
||||||
COMP_ERROR(w->base.c, "Invalid non-desktop reply");
|
COMP_ERROR(w->base.c, "Invalid non-desktop reply");
|
||||||
free(name_str);
|
free(name_str);
|
||||||
|
free(prop_reply);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,8 +890,12 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w)
|
||||||
w->randr_displays.push_back(d);
|
w->randr_displays.push_back(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(prop_reply);
|
||||||
|
free(output_reply);
|
||||||
free(name_str);
|
free(name_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(resources_reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -301,6 +301,7 @@ comp_window_xcb_get_randr_outputs(comp_window_xcb *w)
|
||||||
if (output_reply->connection !=
|
if (output_reply->connection !=
|
||||||
XCB_RANDR_CONNECTION_CONNECTED ||
|
XCB_RANDR_CONNECTION_CONNECTED ||
|
||||||
output_reply->crtc == XCB_NONE) {
|
output_reply->crtc == XCB_NONE) {
|
||||||
|
free(output_reply);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,8 +326,12 @@ comp_window_xcb_get_randr_outputs(comp_window_xcb *w)
|
||||||
d.size = {crtc_reply->width, crtc_reply->height};
|
d.size = {crtc_reply->width, crtc_reply->height};
|
||||||
w->displays.push_back(d);
|
w->displays.push_back(d);
|
||||||
|
|
||||||
|
free(crtc_reply);
|
||||||
|
free(output_reply);
|
||||||
free(name_str);
|
free(name_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(resources_reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue