Skip to content

Commit

Permalink
Check the result of malloc in string_list_add (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesmz committed May 30, 2024
1 parent 35a3293 commit e45d846
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/server/ns_turn_maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e45d846

Please sign in to comment.