]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0471: vimvars di_key initialized at runtime v9.2.0471
authorJohn Marriott <basilisk@internode.on.net>
Mon, 11 May 2026 16:22:05 +0000 (16:22 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 11 May 2026 16:22:05 +0000 (16:22 +0000)
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 <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/evalvars.c
src/version.c

index 1df4af99728a654a1825fcb7f842f6c1336672c2..9b98ae731011aa3b0d4bc222a348cf65a5c38f82 100644 (file)
@@ -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)
index 5e5f17f85a2871b7f1644540e840b218be6397de..875c6f6740dfdd6de7153e9afe86cd6fa188dbb9 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    471,
 /**/
     470,
 /**/