From 705a2c565b514d131997cc081a3979e7146444a3 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 16 Mar 2019 01:07:03 +0100 Subject: [PATCH] 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. --- .../ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c index 797eb78c9..2bf15a3a8 100644 --- a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c +++ b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c @@ -398,7 +398,7 @@ uint8_t USBD_HID_SendReport (USBD_HandleTypeDef *pdev, { 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) {