patch 9.1.1242: Crash when evaluating variable name

Problem:  Crash when evaluating variable name (after v9.1.0870)
Solution: calculate the strlen() directly instead of pointer
          arithmetics, fix missing assignment to lp->ll_name_end in
          get_lval() (zeertzjq)

closes: #16972
fixes: vim-airline/vim-airline#2710
related: #16066

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-03-26 19:25:57 +01:00
parent 4dd17a90ee
commit 06774a271a
2 changed files with 5 additions and 1 deletions

View File

@ -2163,6 +2163,8 @@ get_lval(
}
}
lp->ll_name = lp->ll_exp_name;
if (lp->ll_name != NULL)
lp->ll_name_end = lp->ll_name + STRLEN(lp->ll_name);
}
else
{
@ -2373,7 +2375,7 @@ set_var_lval(
// handle +=, -=, *=, /=, %= and .=
di = NULL;
if (eval_variable(lp->ll_name, (int)(lp->ll_name_end - lp->ll_name),
if (eval_variable(lp->ll_name, (int)STRLEN(lp->ll_name),
lp->ll_sid, &tv, &di, EVAL_VAR_VERBOSE) == OK)
{
if (di != NULL && check_typval_is_value(&di->di_tv) == FAIL)