summaryrefslogtreecommitdiff
blob: 714d733f3689160f8ebca6796b6f4acb21c7ebfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
https://github.com/altdesktop/python-dbus-next/pull/114
https://github.com/altdesktop/python-dbus-next/issues/113
https://gitlab.gnome.org/GNOME/pygobject/-/issues/525

From 445bc2cd0df80e36154e45ea3c4f268b550890b5 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue, 22 Mar 2022 22:11:01 +1000
Subject: [PATCH] glib: destroy the _AuthLineSource explicitly

See https://gitlab.gnome.org/GNOME/pygobject/-/issues/525 for an
explanation, the summary is: we need to explicitly call source.destroy()
if dispatch returns GLib.SOURCE_REMOVE.

Deleting the source by resetting it to None causes invalid memory
accesses and eventual crashes.

This can be reproduced with a basic call to
    bus = dbus_next.glib.MessageBus(bus_type=dbus_next.BusType.SESSION).connect_sync()
and a GLib.MainLoop() after this call. Run in valgrind --tool=memcheck.

Fixes #113
--- a/dbus_next/glib/message_bus.py
+++ b/dbus_next/glib/message_bus.py
@@ -457,7 +457,7 @@ def line_notify(line):
                 self._stream.write(Authenticator._format_line(resp))
                 self._stream.flush()
                 if resp == 'BEGIN':
-                    self._readline_source = None
+                    self._readline_source.destroy()
                     authenticate_notify(None)
                     return True
             except Exception as e: