diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-01 18:07:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 18:07:09 +0800 |
commit | 01d3a64e284749ac1ae40b0caf7165155063fc4f (patch) | |
tree | b8a0be55fe150d73a6a712d784c000ce19402396 /src/nvim/syntax.c | |
parent | d63ad600e0571ccf07eed1e841e8519da7d4af9f (diff) | |
download | rneovim-01d3a64e284749ac1ae40b0caf7165155063fc4f.tar.gz rneovim-01d3a64e284749ac1ae40b0caf7165155063fc4f.tar.bz2 rneovim-01d3a64e284749ac1ae40b0caf7165155063fc4f.zip |
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)
https://github.com/vim/vim/commit/47ed553fd5bebfc36eb8aa81686eeaa5a84eccac
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 05c570e52f..49b63ad324 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -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; |