summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-01 13:11:15 +0000
committerBram Moolenaar <Bram@vim.org>2023-02-01 13:11:15 +0000
commit1b438a8228a415720efb5ca1c0503f5467292e8e (patch)
treec0594ccd7e5f15daebb599474a87d5cd394a2652 /src/evalvars.c
parenta7d36b732070944aab614944075ec0b409311482 (diff)
patch 9.0.1271: using sizeof() and subtract array size is trickyv9.0.1271
Problem: Using sizeof() and subtract array size is tricky. Solution: Use offsetof() instead. (closes #11926)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 066543669b..b2343c0a2b 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -3960,7 +3960,7 @@ set_var_const(
|| STRNCMP(name, "g:", 2) == 0 || var_in_autoload))
goto failed;
- di = alloc(sizeof(dictitem_T) + STRLEN(varname));
+ di = alloc(offsetof(dictitem_T, di_key) + STRLEN(varname) + 1);
if (di == NULL)
goto failed;
STRCPY(di->di_key, varname);