}
/* Did we hit an unexpected descriptor? */
- usbi_parse_descriptor(buffer, "bb", &header, 0);
- if ((size >= DESC_HEADER_LENGTH) &&
- ((header.bDescriptorType == LIBUSB_DT_CONFIG) ||
- (header.bDescriptorType == LIBUSB_DT_DEVICE)))
- return parsed;
+ if (size >= DESC_HEADER_LENGTH) {
+ usbi_parse_descriptor(buffer, "bb", &header, 0);
+ if ((header.bDescriptorType == LIBUSB_DT_CONFIG) ||
+ (header.bDescriptorType == LIBUSB_DT_DEVICE)) {
+ return parsed;
+ }
+ }
if (ifp->bNumEndpoints > USB_MAXENDPOINTS) {
usbi_err(ctx, "too many endpoints (%d)", ifp->bNumEndpoints);