Skip to content

Commit

Permalink
hid_open_path: Don't pass invalid pointers to HidD_FreePreparsedData
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Megamouse authored and Megamouse committed Jan 26, 2022
1 parent 8ff2dee commit 0abd328
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion windows/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0abd328

Please sign in to comment.