[mutter] backends/x11: Free button state mask allocated by XIQueryPointer



commit 7dd4ae339cd7057bd5b80b68e9b53f67af0c5817
Author: Sebastian Keller <skeller gnome org>
Date:   Thu Feb 11 15:44:37 2021 +0100

    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>

 src/backends/x11/meta-input-device-x11.c |  4 +++-
 src/backends/x11/meta-seat-x11.c         | 13 ++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/backends/x11/meta-input-device-x11.c b/src/backends/x11/meta-input-device-x11.c
index 999237a54c..d40dd83371 100644
--- a/src/backends/x11/meta-input-device-x11.c
+++ b/src/backends/x11/meta-input-device-x11.c
@@ -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;
 
diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c
index 6ae6f5f3b5..5b899114d9 100644
--- a/src/backends/x11/meta-seat-x11.c
+++ b/src/backends/x11/meta-seat-x11.c
@@ -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;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]