mirror of
https://github.com/coturn/coturn.git
synced 2025-05-14 09:36:49 +08:00
Check the result of malloc in string_list_add (#1495)
This commit is contained in:
parent
35a3293531
commit
e45d846331
@ -838,9 +838,16 @@ static string_list *string_list_add(string_list *sl, const ur_string_map_key_typ
|
||||
return sl;
|
||||
}
|
||||
string_elem *elem = (string_elem *)malloc(sizeof(string_elem));
|
||||
if (!elem) {
|
||||
return sl;
|
||||
}
|
||||
elem->list.next = sl;
|
||||
elem->key_size = strlen(key) + 1;
|
||||
elem->key = (char *)malloc(elem->key_size);
|
||||
if (!elem->key) {
|
||||
free(elem);
|
||||
return sl;
|
||||
}
|
||||
memcpy(elem->key, key, elem->key_size);
|
||||
elem->value = value;
|
||||
return &(elem->list);
|
||||
|
Loading…
x
Reference in New Issue
Block a user