aboutsummaryrefslogtreecommitdiffstats
path: root/main/upower/linux-Fix-possible-double-free.patch
blob: d63cf4d11dfb1baae5e5c761f7f8c35fbe9869a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From c9b2e177267b623850b3deedb1242de7d2e413ee Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 26 Jun 2015 14:07:13 +0200
Subject: linux: Fix possible double-free

When reopening the lockdown daemon with upower as the client, don't
double-free if the user says "No" to trusting the laptop.

https://bugzilla.redhat.com/show_bug.cgi?id=1231763

diff --git a/src/linux/up-device-idevice.c b/src/linux/up-device-idevice.c
index 9722774..6ab1bf8 100644
--- a/src/linux/up-device-idevice.c
+++ b/src/linux/up-device-idevice.c
@@ -74,7 +74,7 @@ start_poll_cb (UpDeviceIdevice *idevice)
 	UpDevice *device = UP_DEVICE (idevice);
 	idevice_t dev = NULL;
 	lockdownd_client_t client = NULL;
-	char *uuid;
+	char *uuid = NULL;
 
 	g_object_get (G_OBJECT (idevice), "serial", &uuid, NULL);
 	g_assert (uuid);
@@ -83,7 +83,7 @@ start_poll_cb (UpDeviceIdevice *idevice)
 	if (idevice_new (&dev, uuid) != IDEVICE_E_SUCCESS)
 		goto out;
 
-	g_free (uuid);
+	g_clear_pointer (&uuid, g_free);
 
 	if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake (dev, &client, "upower"))
 		goto out;
@@ -111,7 +111,7 @@ start_poll_cb (UpDeviceIdevice *idevice)
 out:
 	g_clear_pointer (&client, lockdownd_client_free);
 	g_clear_pointer (&dev, idevice_free);
-	g_free (uuid);
+	g_clear_pointer (&uuid, g_free);
 	return G_SOURCE_CONTINUE;
 }
 
-- 
cgit v0.10.2