Handle NULL return from SDL_DBus_GetContext()
authorSam Lantinga <slouken@libsdl.org>
Mon, 23 Apr 2018 20:24:12 -0700
changeset 119492db064e4a284
parent 11948 b6ad849f76a4
child 11950 2a7839691e3d
Handle NULL return from SDL_DBus_GetContext()
src/power/linux/SDL_syspower.c
     1.1 --- a/src/power/linux/SDL_syspower.c	Mon Apr 23 19:20:12 2018 -0700
     1.2 +++ b/src/power/linux/SDL_syspower.c	Mon Apr 23 20:24:12 2018 -0700
     1.3 @@ -608,12 +608,12 @@
     1.4  {
     1.5      SDL_bool retval = SDL_FALSE;
     1.6  
     1.7 -    #if SDL_USE_LIBDBUS
     1.8 +#if SDL_USE_LIBDBUS
     1.9      SDL_DBusContext *dbus = SDL_DBus_GetContext();
    1.10      char **paths = NULL;
    1.11      int i, numpaths = 0;
    1.12  
    1.13 -    if (!SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices",
    1.14 +    if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices",
    1.15              DBUS_TYPE_INVALID,
    1.16              DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) {
    1.17          return SDL_FALSE;  /* try a different approach than UPower. */
    1.18 @@ -631,7 +631,7 @@
    1.19      if (dbus) {
    1.20          dbus->free_string_array(paths);
    1.21      }
    1.22 -    #endif  /* SDL_USE_LIBDBUS */
    1.23 +#endif  /* SDL_USE_LIBDBUS */
    1.24  
    1.25      return retval;
    1.26  }