[PATCH 06/10] hidpp: fix memleak for each Feature

Peter Wu peter at lekensteyn.nl
Wed Nov 26 03:21:13 PST 2014


The name of each Logitech HID++ 2.0 Feature will now be freed.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
---
 src/linux/hidpp-device.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index 106f55a..9a651d8 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -1015,6 +1015,17 @@ out:
 }
 
 /**
+ * hidpp_device_free_feature:
+ **/
+static void
+hidpp_device_free_feature (gpointer data)
+{
+	HidppDeviceMap *map = data;
+	g_free (map->name);
+	g_free (map);
+}
+
+/**
  * hidpp_device_init:
  **/
 static void
@@ -1024,7 +1035,7 @@ hidpp_device_init (HidppDevice *device)
 
 	device->priv = HIDPP_DEVICE_GET_PRIVATE (device);
 	device->priv->fd = -1;
-	device->priv->feature_index = g_ptr_array_new_with_free_func (g_free);
+	device->priv->feature_index = g_ptr_array_new_with_free_func (hidpp_device_free_feature);
 	device->priv->batt_status = HIDPP_DEVICE_BATT_STATUS_UNKNOWN;
 	device->priv->kind = HIDPP_DEVICE_KIND_UNKNOWN;
 	device->priv->lux = -1;
-- 
2.1.3



More information about the devkit-devel mailing list