From a9ae1b508d827dac54b2b54557e72d448d4cbae3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 23 Apr 2018 20:24:12 -0700 Subject: [PATCH] Handle NULL return from SDL_DBus_GetContext() --- src/power/linux/SDL_syspower.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index 105d5fe7f..e6c0c1c3d 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -608,12 +608,12 @@ SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, int *second { SDL_bool retval = SDL_FALSE; - #if SDL_USE_LIBDBUS +#if SDL_USE_LIBDBUS SDL_DBusContext *dbus = SDL_DBus_GetContext(); char **paths = NULL; int i, numpaths = 0; - if (!SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", + if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", DBUS_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) { return SDL_FALSE; /* try a different approach than UPower. */ @@ -631,7 +631,7 @@ SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, int *second if (dbus) { dbus->free_string_array(paths); } - #endif /* SDL_USE_LIBDBUS */ +#endif /* SDL_USE_LIBDBUS */ return retval; }