summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2019-10-24 14:27:37 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2019-10-24 14:27:37 +1000
commit8a75da773e19f812c088dc87b82a2232e3bce032 (patch)
treeb796669f234bd6c3411417d7615d505bf9b62bdb /udev
parent727a504e0d1bd09432e148429964641f0f4a4ff7 (diff)
downloadlibinput-8a75da773e19f812c088dc87b82a2232e3bce032.tar.gz
udev: fix potential memory leak for the phys string
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'udev')
-rw-r--r--udev/libinput-device-group.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/udev/libinput-device-group.c b/udev/libinput-device-group.c
index dfcf9e0a..46348e00 100644
--- a/udev/libinput-device-group.c
+++ b/udev/libinput-device-group.c
@@ -95,7 +95,7 @@ static void
wacom_handle_ekr(struct udev_device *device,
int *vendor_id,
int *product_id,
- const char **phys_attr)
+ char **phys_attr)
{
struct udev *udev;
struct udev_enumerate *e;
@@ -138,7 +138,7 @@ wacom_handle_ekr(struct udev_device *device,
*product_id = pid;
best_dist = dist;
- free((char*)*phys_attr);
+ free(*phys_attr);
*phys_attr = strdup(phys);
}
}
@@ -155,8 +155,7 @@ int main(int argc, char **argv)
struct udev *udev = NULL;
struct udev_device *device = NULL;
const char *syspath,
- *phys = NULL,
- *physmatch = NULL;
+ *phys = NULL;
const char *product;
int bustype, vendor_id, product_id, version;
char group[1024];
@@ -208,6 +207,8 @@ int main(int argc, char **argv)
&version) != 4) {
snprintf(group, sizeof(group), "%s:%s", product, phys);
} else {
+ char *physmatch = NULL;
+
#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
if (vendor_id == VENDOR_ID_WACOM) {
if (product_id == PRODUCT_ID_WACOM_EKR)
@@ -228,6 +229,8 @@ int main(int argc, char **argv)
vendor_id,
product_id,
physmatch ? physmatch : phys);
+
+ free(physmatch);
}
str = strstr(group, "/input");