Skip to content

Commit

Permalink
Add missing allocation failure check
Browse files Browse the repository at this point in the history
  • Loading branch information
rom1v committed Jul 19, 2022
1 parent 396e4bd commit 4aeb78e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/usb/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4aeb78e

Please sign in to comment.