mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 11:19:14 +02:00
udev: fix potential memory leak for the phys string
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
727a504e0d
commit
8a75da773e
1 changed files with 7 additions and 4 deletions
|
|
@ -95,7 +95,7 @@ static void
|
||||||
wacom_handle_ekr(struct udev_device *device,
|
wacom_handle_ekr(struct udev_device *device,
|
||||||
int *vendor_id,
|
int *vendor_id,
|
||||||
int *product_id,
|
int *product_id,
|
||||||
const char **phys_attr)
|
char **phys_attr)
|
||||||
{
|
{
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
struct udev_enumerate *e;
|
struct udev_enumerate *e;
|
||||||
|
|
@ -138,7 +138,7 @@ wacom_handle_ekr(struct udev_device *device,
|
||||||
*product_id = pid;
|
*product_id = pid;
|
||||||
best_dist = dist;
|
best_dist = dist;
|
||||||
|
|
||||||
free((char*)*phys_attr);
|
free(*phys_attr);
|
||||||
*phys_attr = strdup(phys);
|
*phys_attr = strdup(phys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -155,8 +155,7 @@ int main(int argc, char **argv)
|
||||||
struct udev *udev = NULL;
|
struct udev *udev = NULL;
|
||||||
struct udev_device *device = NULL;
|
struct udev_device *device = NULL;
|
||||||
const char *syspath,
|
const char *syspath,
|
||||||
*phys = NULL,
|
*phys = NULL;
|
||||||
*physmatch = NULL;
|
|
||||||
const char *product;
|
const char *product;
|
||||||
int bustype, vendor_id, product_id, version;
|
int bustype, vendor_id, product_id, version;
|
||||||
char group[1024];
|
char group[1024];
|
||||||
|
|
@ -208,6 +207,8 @@ int main(int argc, char **argv)
|
||||||
&version) != 4) {
|
&version) != 4) {
|
||||||
snprintf(group, sizeof(group), "%s:%s", product, phys);
|
snprintf(group, sizeof(group), "%s:%s", product, phys);
|
||||||
} else {
|
} else {
|
||||||
|
char *physmatch = NULL;
|
||||||
|
|
||||||
#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
|
#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
|
||||||
if (vendor_id == VENDOR_ID_WACOM) {
|
if (vendor_id == VENDOR_ID_WACOM) {
|
||||||
if (product_id == PRODUCT_ID_WACOM_EKR)
|
if (product_id == PRODUCT_ID_WACOM_EKR)
|
||||||
|
|
@ -228,6 +229,8 @@ int main(int argc, char **argv)
|
||||||
vendor_id,
|
vendor_id,
|
||||||
product_id,
|
product_id,
|
||||||
physmatch ? physmatch : phys);
|
physmatch ? physmatch : phys);
|
||||||
|
|
||||||
|
free(physmatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
str = strstr(group, "/input");
|
str = strstr(group, "/input");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue