Fix memory corruption in USB code.

Crash occurs on my machine shortly after power up.  `hhid` is null at
the time it occurs so the change to `hhid->state` causes a crash.
This commit is contained in:
Dominic Clifton 2019-03-16 01:07:03 +01:00
parent 2db432a2b7
commit 705a2c565b
1 changed files with 1 additions and 1 deletions

View File

@ -398,7 +398,7 @@ uint8_t USBD_HID_SendReport (USBD_HandleTypeDef *pdev,
{ {
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef*)pdev->pHID_ClassData; USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef*)pdev->pHID_ClassData;
if (pdev->dev_state == USBD_STATE_CONFIGURED ) if (pdev->dev_state == USBD_STATE_CONFIGURED && hhid)
{ {
if(hhid->state == HID_IDLE) if(hhid->state == HID_IDLE)
{ {