This one is an actual issue. Instead of properly allocating an array of pointers, an array of sequential descriptors was being used. Not much of an impact, but obvious waste in memory. The attached patch addresses this.

Like the previous one, I plan to apply this fix in time for 1.0.12.

I'm also not forgetting about the xusb wording change for "USB LowSpeed", but I'm waiting to see if there's anything else we may want to apply to xusb for 1.0.12.

Regards,

/Pete
>From 8ea0ca3bf3acd7974535fa0713ddc14a0fe45f9c Mon Sep 17 00:00:00 2001
From: Pete Batard <p...@akeo.ie>
Date: Wed, 13 Jun 2012 13:38:46 +0100
Subject: [PATCH 2/2] Windows: Fix erroneous pointer array allocation reported
 by Clang

* Result of 'calloc' is converted to a pointer of type 'unsigned char *',
  which is incompatible with sizeof operand type 'PUSB_CONFIGURATION_DESCRIPTOR'
* priv->config_descriptor is indeed an array of pointers, with each descriptor
  allocated, rather than a sequential list of fixed descriptor.
---
 libusb/os/windows_usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 98b26eb..461633b 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -901,7 +901,7 @@ static int cache_config_descriptors(struct libusb_device 
*dev, HANDLE hub_handle
        if (dev->num_configurations == 0)
                return LIBUSB_ERROR_INVALID_PARAM;
 
-       priv->config_descriptor = (unsigned char**) 
calloc(dev->num_configurations, sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
+       priv->config_descriptor = (unsigned char**) 
calloc(dev->num_configurations, sizeof(unsigned char*));
        if (priv->config_descriptor == NULL)
                return LIBUSB_ERROR_NO_MEM;
        for (i=0; i<dev->num_configurations; i++)
-- 
1.7.10.msysgit.1

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to