mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user