Commit 379d4780559690a9836444aeb5637f60953947be

Ludovico de Nittis 2022-09-28T10:25:24

dbus: guard against uninitialized D-Bus Before calling any D-Bus related methods we should first ensure that they were correctly loaded. In the event where `LoadDBUSLibrary()` was not able to load the D-Bus library, we should just return early, signalling with SDL_FALSE that we were unable to inhibit the Screensaver. Helps: https://github.com/ValveSoftware/steam-for-linux/issues/8815 Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c
index 3ab362d..9153e50 100644
--- a/src/core/linux/SDL_dbus.c
+++ b/src/core/linux/SDL_dbus.c
@@ -419,6 +419,12 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
         return SDL_TRUE;
     }
 
+    if (!dbus.session_conn) {
+        /* We either lost connection to the session bus or were not able to
+         * load the D-Bus library at all. */
+        return SDL_FALSE;
+    }
+
     if (SDL_DetectSandbox() != SDL_SANDBOX_NONE) {
         const char *bus_name = "org.freedesktop.portal.Desktop";
         const char *path = "/org/freedesktop/portal/desktop";