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/spellsuggest.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/spellsuggest.c')
-rw-r--r-- | src/nvim/spellsuggest.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index 22add418a0..54b6f552b5 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -2828,7 +2828,7 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len, hash); if (HASHITEM_EMPTY(hi)) { - sft = xmalloc(sizeof(sftword_T) + goodword_len); + sft = xmalloc(offsetof(sftword_T, sft_word) + goodword_len + 1); sft->sft_score = (int16_t)score; memcpy(sft->sft_word, goodword, goodword_len + 1); hash_add_item(&slang->sl_sounddone, hi, (char *)sft->sft_word, hash); |