diff --git a/src/xrt/compositor/main/comp_window_direct_mode.cpp b/src/xrt/compositor/main/comp_window_direct_mode.cpp index f23796ba5..c953a1107 100644 --- a/src/xrt/compositor/main/comp_window_direct_mode.cpp +++ b/src/xrt/compositor/main/comp_window_direct_mode.cpp @@ -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."); } + free(version_reply); + xcb_generic_error_t *error = nullptr; xcb_intern_atom_cookie_t non_desktop_cookie = xcb_intern_atom( 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 // (it is possible to see 'ghost' outputs with non-desktop=1). if (output_reply->num_modes == 0) { + free(output_reply); continue; } @@ -836,12 +839,14 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w) "returned error %d", error->error_code); free(name_str); + free(prop_reply); continue; } if (prop_reply == nullptr) { COMP_ERROR(w->base.c, "property reply == nullptr"); free(name_str); + free(prop_reply); 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) { COMP_ERROR(w->base.c, "Invalid non-desktop reply"); free(name_str); + free(prop_reply); continue; } @@ -884,8 +890,12 @@ comp_window_direct_get_randr_outputs(struct comp_window_direct *w) w->randr_displays.push_back(d); } + free(prop_reply); + free(output_reply); free(name_str); } + + free(resources_reply); } static void diff --git a/src/xrt/compositor/main/comp_window_xcb.cpp b/src/xrt/compositor/main/comp_window_xcb.cpp index 6201db3e7..4226713bf 100644 --- a/src/xrt/compositor/main/comp_window_xcb.cpp +++ b/src/xrt/compositor/main/comp_window_xcb.cpp @@ -301,6 +301,7 @@ comp_window_xcb_get_randr_outputs(comp_window_xcb *w) if (output_reply->connection != XCB_RANDR_CONNECTION_CONNECTED || output_reply->crtc == XCB_NONE) { + free(output_reply); continue; } @@ -325,8 +326,12 @@ comp_window_xcb_get_randr_outputs(comp_window_xcb *w) d.size = {crtc_reply->width, crtc_reply->height}; w->displays.push_back(d); + free(crtc_reply); + free(output_reply); free(name_str); } + + free(resources_reply); } static void