mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
vim-patch:9.0.1271: using sizeof() and subtract array size is tricky (#22087)
Problem: Using sizeof() and subtract array size is tricky.
Solution: Use offsetof() instead. (closes vim/vim#11926)
1b438a8228
This commit is contained in:
@@ -2514,7 +2514,7 @@ static void store_sb_text(char **sb_str, char *s, int attr, int *sb_col, int fin
|
||||
}
|
||||
|
||||
if (s > *sb_str) {
|
||||
mp = xmalloc((sizeof(msgchunk_T) + (size_t)(s - *sb_str)));
|
||||
mp = xmalloc(offsetof(msgchunk_T, sb_text) + (size_t)(s - *sb_str) + 1);
|
||||
mp->sb_eol = (char)finish;
|
||||
mp->sb_msg_col = *sb_col;
|
||||
mp->sb_attr = attr;
|
||||
|
Reference in New Issue
Block a user