diff options
Diffstat (limited to 'executor/common_usb.h')
| -rw-r--r-- | executor/common_usb.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/executor/common_usb.h b/executor/common_usb.h index 1442bef47..bf8d9b6d7 100644 --- a/executor/common_usb.h +++ b/executor/common_usb.h @@ -418,8 +418,13 @@ struct vusb_responses { static bool lookup_control_response(struct vusb_descriptors* descs, struct vusb_responses* resps, struct usb_ctrlrequest* ctrl, char** response_data, uint32* response_length) { - int descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]); - int resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]); + int descs_num = 0; + int resps_num = 0; + + if (descs) + descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]); + if (resps) + resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]); uint8 req = ctrl->bRequest; uint8 req_type = ctrl->bRequestType & USB_TYPE_MASK; |
