From 4aeb78ece280d44607eda23f7996bae3d0c9415a Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 19 Jul 2022 12:17:02 +0200 Subject: [PATCH] Add missing allocation failure check --- app/src/usb/usb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/usb/usb.c b/app/src/usb/usb.c index 97aa9a33..190a4108 100644 --- a/app/src/usb/usb.c +++ b/app/src/usb/usb.c @@ -23,6 +23,11 @@ read_string(libusb_device_handle *handle, uint8_t desc_index) { // When non-negative, 'result' contains the number of bytes written char *s = malloc(result + 1); + if (!s) { + LOG_OOM(); + return NULL; + } + memcpy(s, buffer, result); s[result] = '\0'; return s;