Add missing allocation failure check
This commit is contained in:
parent
396e4bd925
commit
4aeb78ece2
1 changed files with 5 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue