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.
This commit is contained in:
parent
107fdfde32
commit
ff0107fc0a
1 changed files with 4 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue