aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spellfile.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-01 21:53:32 +0800
committerGitHub <noreply@github.com>2023-02-01 21:53:32 +0800
commit4cc0d6b854b44c0b8466e0a84bbc9e350cda8c4f (patch)
treef9ce4ba1049537d3371f009c5b90b115d1e571f2 /src/nvim/spellfile.c
parenta26c0ecab610021e6ff6d9d738173a69ecd30fcc (diff)
downloadrneovim-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/spellfile.c')
-rw-r--r--src/nvim/spellfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 44414ca1a5..7b124ae6b6 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -3855,7 +3855,7 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align)
if (bl == NULL || (size_t)bl->sb_used + len > SBLOCKSIZE) {
// Allocate a block of memory. It is not freed until much later.
- bl = xcalloc(1, (sizeof(sblock_T) + SBLOCKSIZE));
+ bl = xcalloc(1, offsetof(sblock_T, sb_data) + SBLOCKSIZE + 1);
bl->sb_next = spin->si_blocks;
spin->si_blocks = bl;
bl->sb_used = 0;