Browse Source

flash: Fix GVariant leaks

All functions used there are transfer: full but only two of
them were freed.
Guido Günther 3 years ago
parent
commit
c6db1ab680
1 changed files with 3 additions and 5 deletions
  1. 3 5
      src/flash.c

+ 3 - 5
src/flash.c

@@ -140,22 +140,20 @@ static void
 brightness_received(GDBusProxy *proxy, GAsyncResult *res, gpointer user_data)
 {
         g_autoptr(GError) error = NULL;
-        GVariant *result = g_dbus_proxy_call_finish(proxy, res, &error);
+        g_autoptr(GVariant) result = g_dbus_proxy_call_finish(proxy, res, &error);
 
         if (!result) {
                 printf("Failed to get display brightness: %s\n", error->message);
                 return;
         }
 
-        GVariant *values = g_variant_get_child_value(result, 0);
+        g_autoptr(GVariant) values = g_variant_get_child_value(result, 0);
         if (g_variant_n_children(values) == 0) {
                 return;
         }
 
-        GVariant *brightness = g_variant_get_child_value(values, 0);
+        g_autoptr(GVariant) brightness = g_variant_get_child_value(values, 0);
         dbus_old_brightness = g_variant_get_int32(brightness);
-
-        g_variant_unref(result);
 }
 
 static bool