[glib: 2/5] gpowerprofilemonitordbus: Fix a crash if no property is cached




commit a37b9d8652a59e95bbf838779c162e0a7f14b1c8
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Sep 6 18:55:04 2021 +0100

    gpowerprofilemonitordbus: Fix a crash if no property is cached
    
    It’s not always guaranteed that a property is cached, so handle the case
    when it isn’t.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/gpowerprofilemonitordbus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gio/gpowerprofilemonitordbus.c b/gio/gpowerprofilemonitordbus.c
index 2bf7212b8..cbd9f4aaa 100644
--- a/gio/gpowerprofilemonitordbus.c
+++ b/gio/gpowerprofilemonitordbus.c
@@ -116,7 +116,8 @@ ppd_proxy_cb (GObject      *source_object,
     }
 
   active_profile_variant = g_dbus_proxy_get_cached_property (proxy, "ActiveProfile");
-  if (g_variant_is_of_type (active_profile_variant, G_VARIANT_TYPE_STRING))
+  if (active_profile_variant != NULL &&
+      g_variant_is_of_type (active_profile_variant, G_VARIANT_TYPE_STRING))
     {
       active_profile = g_variant_get_string (active_profile_variant, NULL);
       power_saver_enabled = g_strcmp0 (active_profile, "power-saver") == 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]