A Zig library for talking to USB and Bluetooth HID devices on Linux, FreeBSD, Windows and macOS, without linking the C hidapi

close the device when querying it fails

next opened /dev/hidrawN and guarded it with an errdefer before asking for its DeviceInfo, but errdefer only runs when the scope is left by returning an error, and the query is followed by catch continue. Since both fallible calls in the loop are caught, next never returns an error at all, so that errdefer could not fire under any circumstances. A device that opened but would not answer HIDIOCGRAWINFO was left open and its descriptor leaked for the life of the process. Close it explicitly on that path instead, with a comment recording why the errdefer that used to be there did nothing, so it does not come back. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JRS7gtG7BeWuwFUf8xW4qS


Author jcollie.dev
Co-author Claude Opus 5 (1M context) Date Commit Parent f8657512
+7 -2
1 changed file
+7 -2
1 changed file