mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
vim-patch:8.1.1827: allocating more memory than needed for extended structs (#22081)
Problem: Allocating more memory than needed for extended structs.
Solution: Use offsetof() instead of sizeof(). (Dominique Pelle,
closes vim/vim#4786)
47ed553fd5
This commit is contained in:
@@ -103,7 +103,7 @@ static signgroup_T *sign_group_ref(const char *groupname)
|
||||
hi = hash_lookup(&sg_table, (char *)groupname, strlen(groupname), hash);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
// new group
|
||||
group = xmalloc(sizeof(signgroup_T) + strlen(groupname));
|
||||
group = xmalloc(offsetof(signgroup_T, sg_name) + strlen(groupname) + 1);
|
||||
|
||||
STRCPY(group->sg_name, groupname);
|
||||
group->sg_refcount = 1;
|
||||
|
Reference in New Issue
Block a user