summaryrefslogtreecommitdiff
path: root/libusb/os/windows_usb.c
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-02-10 00:51:54 +0000
committerPete Batard <pbatard@gmail.com>2010-02-10 00:51:54 +0000
commit36d76382a06d00c936e881acb60c69cbb91d679f (patch)
treebd6966815b1c44e3114cbab98967186251a46731 /libusb/os/windows_usb.c
parent36e4414a3504f054bfd66b591e20a4c21a16df98 (diff)
downloadlibusb-36d76382a06d00c936e881acb60c69cbb91d679f.tar.gz
fixed memory leak dues to HID collections in set_composite_devicer146
Diffstat (limited to 'libusb/os/windows_usb.c')
-rw-r--r--libusb/os/windows_usb.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 176c5db..425dc1a 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -1135,13 +1135,22 @@ enum libusb_hid_report_type {
for (j=0; j<nb_paths; j++) {
if ( (safe_strncmp(sanitized_path[j], sanitized_short, strlen(sanitized_short)) == 0)
|| (safe_strcmp(hid_path[j], sanitized_short) == 0 ) ) {
- priv->usb_interface[interface_number].path = sanitized_path[j];
- priv->usb_interface[interface_number].apib = &usb_api_backend[api_type[j]];
- if ((api_type[j] == USB_API_HID) && (priv->hid == NULL)) {
- priv->hid = calloc(1, sizeof(struct hid_device_priv));
+ // HID devices can have multiple collections (COL##) for each MI_## interface
+ if (priv->usb_interface[interface_number].path != NULL) {
+ usbi_dbg("interface_path[%d] already set - ignoring HID collection: %s",
+ interface_number, sanitized_path[j]);
+ if (api_type[j] != USB_API_HID) {
+ usbi_warn(ctx, "program assertion failed - not an HID collection");
+ }
+ } else {
+ priv->usb_interface[interface_number].path = sanitized_path[j];
+ priv->usb_interface[interface_number].apib = &usb_api_backend[api_type[j]];
+ if ((api_type[j] == USB_API_HID) && (priv->hid == NULL)) {
+ priv->hid = calloc(1, sizeof(struct hid_device_priv));
+ }
+ priv->composite_api_flags |= 1<<api_type[j];
+ sanitized_path[j] = NULL;
}
- priv->composite_api_flags |= 1<<api_type[j];
- sanitized_path[j] = NULL;
}
}
safe_free(sanitized_short);