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:
parent
3c6da8d2b0
commit
ef73c41207
7
usbshm.c
7
usbshm.c
|
@ -130,6 +130,8 @@ int usbshm_open(struct usbshm* instance, int vendorID, int productID, const unsi
|
||||||
if(desc.idVendor == vendorID && desc.idProduct == productID)
|
if(desc.idVendor == vendorID && desc.idProduct == productID)
|
||||||
{
|
{
|
||||||
errorCode = libusb_open(list[i], &instance->priv->handle) < 0 ? USBSHM_ERROR_ERR : 0;
|
errorCode = libusb_open(list[i], &instance->priv->handle) < 0 ? USBSHM_ERROR_ERR : 0;
|
||||||
|
if(errorCode != USBSHM_ERROR_ERR && instance->priv->handle)
|
||||||
|
{
|
||||||
if(serial)
|
if(serial)
|
||||||
{
|
{
|
||||||
size_t len = strlen((const char*)serial)+1;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instance->priv->handle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue