From 3fb773eedd0754eba24111a552f9afdc16bb8b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Mar 2025 10:59:29 +0800 Subject: [PATCH] Gamepad / Mouse / Keyboard (FreeBSD): fix memleaks --- src/detection/gamepad/gamepad_bsd.c | 1 + src/detection/mouse/mouse_bsd.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index fa68b46fc..21631e9a0 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -53,6 +53,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) device->battery = 0; } } + hid_end_parse(hData); } hid_dispose_report_desc(repDesc); diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index cb99a47cf..5052475bf 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -11,12 +11,12 @@ #include // DragonFly #endif -#define MAX_UHID_JOYS 64 +#define MAX_UHID_MICE 64 const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { char path[16]; - for (int i = 0; i < MAX_UHID_JOYS; i++) + for (int i = 0; i < MAX_UHID_MICE; i++) { snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i); FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC); @@ -43,6 +43,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) ffStrbufInitS(&device->name, di.udi_product); } } + hid_end_parse(hData); } hid_dispose_report_desc(repDesc);