Skip to content

Commit 5f66a37

Browse files
MegamouseMegamouse
andauthored
Win32: Don't pass invalid pointers to HidD_FreePreparsedData in hid_open_path (signal11#373)
Fixes a segfault that happens when hid_open_path is called on a previously disconnected device. This is a regression caused by: b600727 - Win32: Fix memory leak in `free_hid_device` (signal11#361) Co-authored-by: Megamouse <[email protected]>
1 parent 0feb5a4 commit 5f66a37

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

windows/hid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,10 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path)
815815
end_of_function:
816816
free(interface_path);
817817
CloseHandle(device_handle);
818-
HidD_FreePreparsedData(pp_data);
818+
819+
if (pp_data) {
820+
HidD_FreePreparsedData(pp_data);
821+
}
819822

820823
return dev;
821824
}

0 commit comments

Comments
 (0)