Mercurial > vim
comparison src/evalvars.c @ 31877:9f28cca2410a v9.0.1271
patch 9.0.1271: using sizeof() and subtract array size is tricky
Commit: https://github.com/vim/vim/commit/1b438a8228a415720efb5ca1c0503f5467292e8e
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed Feb 1 13:11:15 2023 +0000
patch 9.0.1271: using sizeof() and subtract array size is tricky
Problem: Using sizeof() and subtract array size is tricky.
Solution: Use offsetof() instead. (closes https://github.com/vim/vim/issues/11926)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 01 Feb 2023 14:15:04 +0100 |
parents | 7d505d77f6da |
children | 04d9dff67d99 |
comparison
equal
deleted
inserted
replaced
31876:b27dae7424a9 | 31877:9f28cca2410a |
---|---|
3958 // autoload script. | 3958 // autoload script. |
3959 if (!valid_varname(varname, -1, !vim9script | 3959 if (!valid_varname(varname, -1, !vim9script |
3960 || STRNCMP(name, "g:", 2) == 0 || var_in_autoload)) | 3960 || STRNCMP(name, "g:", 2) == 0 || var_in_autoload)) |
3961 goto failed; | 3961 goto failed; |
3962 | 3962 |
3963 di = alloc(sizeof(dictitem_T) + STRLEN(varname)); | 3963 di = alloc(offsetof(dictitem_T, di_key) + STRLEN(varname) + 1); |
3964 if (di == NULL) | 3964 if (di == NULL) |
3965 goto failed; | 3965 goto failed; |
3966 STRCPY(di->di_key, varname); | 3966 STRCPY(di->di_key, varname); |
3967 if (hash_add(ht, DI2HIKEY(di), "add variable") == FAIL) | 3967 if (hash_add(ht, DI2HIKEY(di), "add variable") == FAIL) |
3968 { | 3968 { |