fix issue in usbshm where a open() with specific serial number would segfault if a unresponsive usb device is encountered

This commit is contained in:
Carl Philipp Klemm 2024-02-20 09:41:46 +01:00
parent 3c6da8d2b0
commit ef73c41207

View file

@ -130,6 +130,8 @@ int usbshm_open(struct usbshm* instance, int vendorID, int productID, const unsi
if(desc.idVendor == vendorID && desc.idProduct == productID)
{
errorCode = libusb_open(list[i], &instance->priv->handle) < 0 ? USBSHM_ERROR_ERR : 0;
if(errorCode != USBSHM_ERROR_ERR && instance->priv->handle)
{
if(serial)
{
size_t len = strlen((const char*)serial)+1;
@ -147,6 +149,11 @@ int usbshm_open(struct usbshm* instance, int vendorID, int productID, const unsi
}
break;
}
else
{
instance->priv->handle = NULL;
}
}
}
}
else