Commit: patch 9.2.0471: vimvars di_key initialized at runtime

3 views
Skip to first unread message

Christian Brabandt

unread,
May 11, 2026, 12:30:19 PM (9 days ago) May 11
to vim...@googlegroups.com
patch 9.2.0471: vimvars di_key initialized at runtime

Commit: https://github.com/vim/vim/commit/1b65cfbac5c5bbad108548908e77697111ad4a3f
Author: John Marriott <basi...@internode.on.net>
Date: Mon May 11 16:22:05 2026 +0000

patch 9.2.0471: vimvars di_key initialized at runtime

Problem: evalvars_init() copies each vimvar's name into di_key at
startup and runtime-checks that the name fits in
DICTITEM16_KEY_LEN, even though all names are known at
compile time.
Solution: Embed the name in di_key via the VV_NAME macro so the
initialization happens at compile time. Drop the
runtime length check and the STRCPY loop (John Marriott).

closes: #20185

Signed-off-by: John Marriott <basi...@internode.on.net>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/evalvars.c b/src/evalvars.c
index 1df4af997..9b98ae731 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -37,7 +37,7 @@ static hashtab_T compat_hashtab;
#define VV_RO 2 // read-only
#define VV_RO_SBX 4 // read-only in the sandbox

-#define VV_NAME(s, t) s, {{t, 0, {0}}, 0, {0}}
+#define VV_NAME(s, t) s, {{t, 0, {0}}, 0, {s}}

typedef struct vimvar vimvar_T;

@@ -216,12 +216,6 @@ evalvars_init(void)
for (i = 0; i < VV_LEN; ++i)
{
p = &vimvars[i];
- if (STRLEN(p->vv_name) > DICTITEM16_KEY_LEN)
- {
- iemsg("Name too long, increase size of dictitem16_T");
- getout(1);
- }
- STRCPY(p->vv_di.di_key, p->vv_name);
if (p->vv_flags & VV_RO)
p->vv_di.di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
else if (p->vv_flags & VV_RO_SBX)
diff --git a/src/version.c b/src/version.c
index 5e5f17f85..875c6f674 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 471,
/**/
470,
/**/
Reply all
Reply to author
Forward
0 new messages