mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 21:20:45 +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:
@@ -2862,7 +2862,7 @@ static regprog_T *bt_regcomp(uint8_t *expr, int re_flags)
|
||||
}
|
||||
|
||||
// Allocate space.
|
||||
bt_regprog_T *r = xmalloc(sizeof(bt_regprog_T) + (size_t)regsize);
|
||||
bt_regprog_T *r = xmalloc(offsetof(bt_regprog_T, program) + (size_t)regsize);
|
||||
r->re_in_use = false;
|
||||
|
||||
// Second pass: emit code.
|
||||
|
||||
Reference in New Issue
Block a user