hid_open_path: Don't pass invalid pointers to HidD_FreePreparsedData

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` (#361)
This commit is contained in:
Megamouse 2022-01-26 20:41:02 +01:00
parent cdeb14a4e5
commit 6cf133697c

View File

@ -862,7 +862,10 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path)
end_of_function:
CloseHandle(device_handle);
HidD_FreePreparsedData(pp_data);
if (pp_data) {
HidD_FreePreparsedData(pp_data);
}
return dev;
}