Blob Blame History Raw
From 06894e020a75b9ea670ed524a02b6bf939dc4e9c Mon Sep 17 00:00:00 2001
From: Christian Kellner <christian@kellner.me>
Date: Tue, 8 Jan 2019 17:22:41 +0100
Subject: [PATCH] thunderbolt: fix double free in bolt client

In the async version of the client creation, i.e. when a new client
is created via bolt_client_new_async and an error happens it will be
passed to g_task_return_error which takes ownership of it but the very
same error will also be free'd via g_autoptr; remove the latter.

This is a port of bolt commit e96f8bd47587b167ae46c8ac9347003f69f931dd
---
 panels/thunderbolt/bolt-client.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/panels/thunderbolt/bolt-client.c b/panels/thunderbolt/bolt-client.c
index 0ebc360b1..00038bd7b 100644
--- a/panels/thunderbolt/bolt-client.c
+++ b/panels/thunderbolt/bolt-client.c
@@ -219,7 +219,7 @@ got_the_client (GObject      *source,
                 GAsyncResult *res,
                 gpointer      user_data)
 {
-  g_autoptr(GError) error = NULL;
+  GError *error = NULL;
   GTask *task = user_data;
   GObject *obj;
 
@@ -227,6 +227,7 @@ got_the_client (GObject      *source,
 
   if (obj == NULL)
     {
+      /* error ownership gets transferred to the task */
       g_task_return_error (task, error);
       return;
     }
@@ -240,7 +241,7 @@ got_the_bus (GObject      *source,
              GAsyncResult *res,
              gpointer      user_data)
 {
-  g_autoptr(GError) error = NULL;
+  GError *error = NULL;
   GTask *task = user_data;
   GCancellable *cancellable;
   GDBusConnection *bus;
@@ -249,6 +250,7 @@ got_the_bus (GObject      *source,
   if (bus == NULL)
     {
       g_prefix_error (&error, "could not connect to D-Bus: ");
+      /* error ownership gets transferred to the task */
       g_task_return_error (task, error);
       return;
     }
-- 
2.23.0.rc1