diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-01 21:53:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 21:53:32 +0800 |
commit | 4cc0d6b854b44c0b8466e0a84bbc9e350cda8c4f (patch) | |
tree | f9ce4ba1049537d3371f009c5b90b115d1e571f2 /src/nvim/message.c | |
parent | a26c0ecab610021e6ff6d9d738173a69ecd30fcc (diff) | |
download | rneovim-4cc0d6b854b44c0b8466e0a84bbc9e350cda8c4f.tar.gz rneovim-4cc0d6b854b44c0b8466e0a84bbc9e350cda8c4f.tar.bz2 rneovim-4cc0d6b854b44c0b8466e0a84bbc9e350cda8c4f.zip |
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)
https://github.com/vim/vim/commit/1b438a8228a415720efb5ca1c0503f5467292e8e
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 7f29b19031..3b3dfcd5b6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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; |