Dont let usbshm leak descriptors in usbshm_find
This commit is contained in:
parent
9577eea88b
commit
c3f06de60b
3
usbshm.c
3
usbshm.c
|
@ -125,6 +125,7 @@ int usbshm_find(struct usbshm* instance, int vendorID, int productID, unsigned c
|
||||||
(*serials)[*count] = calloc(16, 1);
|
(*serials)[*count] = calloc(16, 1);
|
||||||
libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (*serials)[*count], 16);
|
libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (*serials)[*count], 16);
|
||||||
++(*count);
|
++(*count);
|
||||||
|
libusb_close(handle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -140,6 +141,8 @@ int usbshm_find(struct usbshm* instance, int vendorID, int productID, unsigned c
|
||||||
return USBSHM_ERROR_ERR;
|
return USBSHM_ERROR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libusb_free_device_list(list, true);
|
||||||
|
|
||||||
pthread_mutex_unlock(instance->mutex);
|
pthread_mutex_unlock(instance->mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue