summaryrefslogtreecommitdiff
path: root/atspi
diff options
context:
space:
mode:
authorMike Gorse <mgorse@suse.com>2023-05-17 16:18:51 -0500
committerMike Gorse <mgorse@suse.com>2023-05-17 16:22:27 -0500
commit37e7d3c77c5175aed382c498bffb876ea0c8581b (patch)
treeaaa62d5538bdf664390673ec6d2641f8f75a0664 /atspi
parent1c4de77eaef8ad644e8a6a8a2e251c84017be324 (diff)
downloadat-spi2-core-main.tar.gz
Hold a reference to the AtspiDevice while processing eventsHEADmain
If this is not done, then the device might be finalized from under us during a callback, leading to a crash.
Diffstat (limited to 'atspi')
-rw-r--r--atspi/atspi-device-legacy.c2
-rw-r--r--atspi/atspi-device-x11.c3
2 files changed, 5 insertions, 0 deletions
diff --git a/atspi/atspi-device-legacy.c b/atspi/atspi-device-legacy.c
index d440483a..84cc2a29 100644
--- a/atspi/atspi-device-legacy.c
+++ b/atspi/atspi-device-legacy.c
@@ -90,6 +90,7 @@ key_cb (AtspiDeviceEvent *event, void *user_data)
gboolean ret = priv->keyboard_grabbed;
guint modifiers;
+ g_object_ref (legacy_device);
set_virtual_modifier (legacy_device, event->hw_code,
event->type == (AtspiEventType) ATSPI_KEY_PRESS);
@@ -104,6 +105,7 @@ key_cb (AtspiDeviceEvent *event, void *user_data)
event->event_string);
g_boxed_free (ATSPI_TYPE_DEVICE_EVENT, event);
+ g_object_unref (legacy_device);
return ret;
}
diff --git a/atspi/atspi-device-x11.c b/atspi/atspi-device-x11.c
index 16fb1636..1c0bee89 100644
--- a/atspi/atspi-device-x11.c
+++ b/atspi/atspi-device-x11.c
@@ -330,6 +330,7 @@ do_event_dispatch (gpointer user_data)
XComposeStatus status;
guint modifiers;
+ g_object_ref (device);
while (XPending (display))
{
XNextEvent (display, &xevent);
@@ -392,6 +393,8 @@ do_event_dispatch (gpointer user_data)
continue;
}
}
+
+ g_object_unref (device);
return TRUE;
}