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