mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 10:26:31 +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:
@@ -3736,7 +3736,7 @@ static void add_keyword(char *const name, const int id, const int flags,
|
||||
sizeof(name_folded))
|
||||
: name;
|
||||
|
||||
keyentry_T *const kp = xmalloc(sizeof(keyentry_T) + strlen(name_ic));
|
||||
keyentry_T *const kp = xmalloc(offsetof(keyentry_T, keyword) + strlen(name_ic) + 1);
|
||||
STRCPY(kp->keyword, name_ic);
|
||||
kp->k_syn.id = (int16_t)id;
|
||||
kp->k_syn.inc_tag = current_syn_inc_tag;
|
||||
|
Reference in New Issue
Block a user