Avoid double free in SinowealthController destructor

* Non USE_HID_USAGE code path needs to avoid closing device twice
This commit is contained in:
Chris M 2024-08-13 20:50:23 +10:00 committed by Adam Honse
parent dd91984b70
commit 31b752feed

View file

@ -30,7 +30,14 @@ SinowealthController::SinowealthController(hid_device* dev_data_handle, hid_devi
SinowealthController::~SinowealthController()
{
hid_close(dev_data);
hid_close(dev_cmd);
/*---------------------------------------------------------------------*\
| If the dev_cmd handle was passed in as the same device as dev_data |
| then attempting to close it a second time will segfault |
\*---------------------------------------------------------------------*/
if(dev_cmd)
{
hid_close(dev_cmd);
}
}
std::string SinowealthController::GetLocation()