changeset 19962:12fa79cac39b v8.2.0537

patch 8.2.0537: Vim9: no check for sandbox when setting v:var Commit: https://github.com/vim/vim/commit/cab2767874dca019083aa371a1f3b45385dbd037 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 9 20:10:55 2020 +0200 patch 8.2.0537: Vim9: no check for sandbox when setting v:var Problem: Vim9: no check for sandbox when setting v:var. Solution: Check for sandbox.
author Bram Moolenaar <Bram@vim.org>
date Thu, 09 Apr 2020 20:15:04 +0200
parents 2a644fc09f28
children 15a32e680c2b
files src/evalvars.c src/testdir/test_vim9_script.vim src/version.c
diffstat 3 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1978,6 +1978,17 @@ set_vim_var_tv(int idx, typval_T *tv)
 	clear_tv(tv);
 	return FAIL;
     }
+    // VV_RO is also checked when compiling, but let's check here as well.
+    if (vimvars[idx].vv_flags & VV_RO)
+    {
+	semsg(_(e_readonlyvar), vimvars[idx].vv_name);
+	return FAIL;
+    }
+    if (sandbox && (vimvars[idx].vv_flags & VV_RO_SBX))
+    {
+	semsg(_(e_readonlysbx), vimvars[idx].vv_name);
+	return FAIL;
+    }
     clear_tv(&vimvars[idx].vv_di.di_tv);
     vimvars[idx].vv_di.di_tv = *tv;
     return OK;
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -170,6 +170,11 @@ def Test_assignment_default()
   assert_equal(5678, nr)
 enddef
 
+def Mess(): string
+  v:foldstart = 123
+  return 'xxx'
+enddef
+
 func Test_assignment_failure()
   call CheckDefFailure(['let var=234'], 'E1004:')
   call CheckDefFailure(['let var =234'], 'E1004:')
@@ -207,6 +212,9 @@ func Test_assignment_failure()
 
   call CheckDefFailure(['let var: dict <number>'], 'E1068:')
   call CheckDefFailure(['let var: dict<number'], 'E1009:')
+
+  call assert_fails('s/^/\=Mess()/n', 'E794:')
+  call CheckDefFailure(['let var: dict<number'], 'E1009:')
 endfunc
 
 func Test_wrong_type()
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    537,
+/**/
     536,
 /**/
     535,