51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
From 460e58128fdbcc1035dc1368003c1e4692dfa55e Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
Date: Thu, 5 Dec 2019 13:16:11 +0100
|
|
Subject: [PATCH 100/181] fp-device: Use different pointers for device handlers
|
|
|
|
A Fp-device use an union to track the handle to the lower-level device, and
|
|
the value depends on the object type.
|
|
|
|
So in case of using a virtual device, the priv->usb_device location matches
|
|
the priv->virtual_env string location, and thus we'd end up unreffing a
|
|
string location as it was a GObject, while we'd leak the string.
|
|
|
|
To avoid such errors, instead of just checking the device type when we
|
|
finalize the device, let's just use different pointers to avoid other
|
|
possible clashes.
|
|
---
|
|
libfprint/fp-device.c | 9 ++++-----
|
|
1 file changed, 4 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c
|
|
index 2f706b3..08023f2 100644
|
|
--- a/libfprint/fp-device.c
|
|
+++ b/libfprint/fp-device.c
|
|
@@ -50,11 +50,8 @@ typedef struct
|
|
{
|
|
FpDeviceType type;
|
|
|
|
- union
|
|
- {
|
|
- GUsbDevice *usb_device;
|
|
- const gchar *virtual_env;
|
|
- };
|
|
+ GUsbDevice *usb_device;
|
|
+ const gchar *virtual_env;
|
|
|
|
gboolean is_open;
|
|
|
|
@@ -382,7 +379,9 @@ fp_device_finalize (GObject *object)
|
|
|
|
g_clear_pointer (&priv->device_id, g_free);
|
|
g_clear_pointer (&priv->device_name, g_free);
|
|
+
|
|
g_clear_object (&priv->usb_device);
|
|
+ g_clear_pointer (&priv->virtual_env, g_free);
|
|
|
|
G_OBJECT_CLASS (fp_device_parent_class)->finalize (object);
|
|
}
|
|
--
|
|
2.24.1
|
|
|