backends/x11: Free button state mask allocated by XIQueryPointer

XIQueryPointer allocates the button state mask that we were leaking in
some places. We need to manually free this, because there is no XI
function that would do this for us.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1728>
This commit is contained in:
Sebastian Keller 2021-02-11 15:44:37 +01:00 committed by Marge Bot
parent 335a85ab84
commit 7dd4ae339c
2 changed files with 13 additions and 4 deletions

View File

@ -401,7 +401,7 @@ meta_input_device_x11_query_pointer_location (MetaInputDeviceX11 *device_xi2)
{
Window xroot_window, xchild_window;
double xroot_x, xroot_y, xwin_x, xwin_y;
XIButtonState button_state;
XIButtonState button_state = { 0 };
XIModifierState mod_state;
XIGroupState group_state;
int result;
@ -419,6 +419,8 @@ meta_input_device_x11_query_pointer_location (MetaInputDeviceX11 *device_xi2)
&group_state);
clutter_x11_untrap_x_errors ();
g_free (button_state.mask);
if (!result)
return FALSE;

View File

@ -1559,7 +1559,7 @@ meta_seat_x11_query_state (ClutterSeat *seat,
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
Window root_ret, child_ret;
double root_x, root_y, win_x, win_y;
XIButtonState button_state;
XIButtonState button_state = { 0 };
XIModifierState modifier_state;
XIGroupState group_state;
@ -1571,7 +1571,10 @@ meta_seat_x11_query_state (ClutterSeat *seat,
&root_x, &root_y, &win_x, &win_y,
&button_state, &modifier_state, &group_state);
if (clutter_x11_untrap_x_errors ())
return FALSE;
{
g_free (button_state.mask);
return FALSE;
}
if (sequence)
{
@ -1579,7 +1582,10 @@ meta_seat_x11_query_state (ClutterSeat *seat,
touch_info = g_hash_table_lookup (seat_x11->touch_coords, sequence);
if (!touch_info)
return FALSE;
{
g_free (button_state.mask);
return FALSE;
}
if (coords)
{
@ -1599,6 +1605,7 @@ meta_seat_x11_query_state (ClutterSeat *seat,
if (modifiers)
*modifiers = translate_state (&button_state, &modifier_state, &group_state);
g_free (button_state.mask);
return TRUE;
}