[USBCCGP]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 28 Feb 2015 09:48:16 +0000 (09:48 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 28 Feb 2015 09:48:16 +0000 (09:48 +0000)
- reset interface count before loop
- add extra checks

svn path=/trunk/; revision=66483

reactos/drivers/usb/usbccgp/descriptor.c

index 4a8a9c8..5537bf9 100644 (file)
@@ -326,6 +326,11 @@ USBCCGP_ScanConfigurationDescriptor(
     // count all interface descriptors
     //
     DescriptorCount = ConfigurationDescriptor->bNumInterfaces;
+    if (DescriptorCount == 0)
+    {
+        DPRINT1("[USBCCGP] DescriptorCount is zero\n");
+        return STATUS_INVALID_PARAMETER;
+    }
 
     //
     // allocate array holding the interface descriptors
@@ -339,6 +344,11 @@ USBCCGP_ScanConfigurationDescriptor(
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
+    //
+    // reset interface list count
+    //
+    FDODeviceExtension->InterfaceListCount = 0;
+
     do
     {
         //
@@ -350,6 +360,7 @@ USBCCGP_ScanConfigurationDescriptor(
             //
             // store in interface list
             //
+            ASSERT(FDODeviceExtension->InterfaceListCount < DescriptorCount);
             FDODeviceExtension->InterfaceList[FDODeviceExtension->InterfaceListCount].InterfaceDescriptor = InterfaceDescriptor;
             FDODeviceExtension->InterfaceListCount++;
         }