1
0
forked from aniani/vim

patch 9.1.0665: Locked variable can be changed in a :for loop

Problem:  Locked variable can be changed in a :for loop.
Solution: Always do a full permission check on the first loop iteration
          where ASSIGN_DECL is not set (zeertzjq).

related: #12470
fixes: #15450
closes: #15454

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-08-08 21:05:57 +02:00
committed by Christian Brabandt
parent 39eff4cdc0
commit 6b97d7ad19
3 changed files with 29 additions and 2 deletions

View File

@@ -4100,7 +4100,7 @@ set_var_const(
// Modifying a final variable with a List value using the "+="
// operator is allowed. For other types, it is not allowed.
if (((flags & ASSIGN_FOR_LOOP) == 0
if ((((flags & ASSIGN_FOR_LOOP) == 0 || (flags & ASSIGN_DECL) == 0)
&& ((flags & ASSIGN_COMPOUND_OP) == 0
|| !type_inplace_modifiable))
? var_check_permission(di, name) == FAIL