mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +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:
@@ -252,7 +252,7 @@ static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t sle
|
||||
} else {
|
||||
len = (size_t)slen;
|
||||
}
|
||||
buffblock_T *p = xmalloc(sizeof(buffblock_T) + len);
|
||||
buffblock_T *p = xmalloc(offsetof(buffblock_T, b_str) + len + 1);
|
||||
buf->bh_space = len - (size_t)slen;
|
||||
xstrlcpy(p->b_str, s, (size_t)slen + 1);
|
||||
|
||||
|
Reference in New Issue
Block a user