[gtk/wip/carlosg/tablet-invalid-reads-master: 2/2] gdk: Avoid poking possibly freed memory



commit 5bb009302a9b9954ac6584f29caf18f1bf3b5307
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Oct 8 17:56:10 2019 +0200

    gdk: Avoid poking possibly freed memory
    
    The event may end up freed after delivery, ensure to keep a ref in order
    to emit the matching emulated crossed event matching a proximity event.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2157

 gdk/wayland/gdkdevice-wayland.c | 4 ++++
 gtk/gtkscrolledwindow.c         | 4 ++++
 2 files changed, 8 insertions(+)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 7a7031d882..1b66f37b3a 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -3327,6 +3327,8 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
   if (!event)
     return;
 
+  g_object_ref (event);
+
   switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
@@ -3367,6 +3369,8 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
     emulate_crossing (event->any.surface, NULL,
                       tablet->master, GDK_ENTER_NOTIFY,
                       GDK_CROSSING_NORMAL, time);
+
+  g_object_unref (event);
 }
 
 static GdkEvent *
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 30c77b0366..c637cfb9d3 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1178,6 +1178,7 @@ captured_scroll_cb (GtkEventControllerScroll *scroll,
                     double                    delta_y,
                     GtkScrolledWindow        *scrolled_window)
 {
+       g_print ("capture..\n");
   gtk_scrolled_window_cancel_deceleration (scrolled_window);
 
   return GDK_EVENT_PROPAGATE;
@@ -1273,6 +1274,7 @@ scroll_controller_scroll (GtkEventControllerScroll *scroll,
   gboolean shifted;
   GdkModifierType state;
 
+  g_print ("bubble..\n");
   if (!gtk_get_current_event_state (&state))
     return GDK_EVENT_PROPAGATE;
 
@@ -1357,6 +1359,8 @@ scroll_controller_decelerate (GtkEventControllerScroll *scroll,
   gboolean shifted;
   GdkModifierType state;
 
+  g_print ("decellll\n");
+
   if (!gtk_get_current_event_state (&state))
     return;
 


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