aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp_nfa.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/regexp_nfa.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/regexp_nfa.c')
-rw-r--r--src/nvim/regexp_nfa.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 93b03f0632..ea59e7d464 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -7511,7 +7511,7 @@ static regprog_T *nfa_regcomp(uint8_t *expr, int re_flags)
post2nfa(postfix, post_ptr, true);
// allocate the regprog with space for the compiled regexp
- size_t prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (size_t)(nstate - 1);
+ size_t prog_size = offsetof(nfa_regprog_T, state) + sizeof(nfa_state_T) * (size_t)nstate;
prog = xmalloc(prog_size);
state_ptr = prog->state;
prog->re_in_use = false;