aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/sign.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-01 18:07:09 +0800
committerGitHub <noreply@github.com>2023-02-01 18:07:09 +0800
commit01d3a64e284749ac1ae40b0caf7165155063fc4f (patch)
treeb8a0be55fe150d73a6a712d784c000ce19402396 /src/nvim/sign.c
parentd63ad600e0571ccf07eed1e841e8519da7d4af9f (diff)
downloadrneovim-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/sign.c')
-rw-r--r--src/nvim/sign.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index d0c093d93a..00e282b76e 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -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;