diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-01 13:17:17 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-01 13:17:17 +0200 |
commit | e97976baa7a74fbbe0cfecd1943fe1c5f9dfba4f (patch) | |
tree | ab5dd99bb09aa67e9dc559d201c114e5059bdbab /src/vim9compile.c | |
parent | 78ba933d18439ff1a02f6be4c571e73ddceb3cd4 (diff) | |
download | vim-git-e97976baa7a74fbbe0cfecd1943fe1c5f9dfba4f.tar.gz |
patch 8.2.3266: Vim9: assignment with two indexes may check next linev8.2.3266
Problem: Vim9: assignment with two indexes may check next line.
Solution: Limit the number of lines to avoid checking the next line when
assiging to a LHS subscript. (closes #8660)
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index cafbd6b2f..9a534f46c 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -6536,19 +6536,25 @@ compile_load_lhs( { size_t varlen = lhs->lhs_varlen; int c = var_start[varlen]; + int lines_len = cctx->ctx_ufunc->uf_lines.ga_len; char_u *p = var_start; garray_T *stack = &cctx->ctx_type_stack; + int res; - // Evaluate "ll[expr]" of "ll[expr][idx]" + // Evaluate "ll[expr]" of "ll[expr][idx]". End the line with a NUL and + // limit the lines array length to avoid skipping to a following line. var_start[varlen] = NUL; - if (compile_expr0(&p, cctx) == OK && p != var_start + varlen) + cctx->ctx_ufunc->uf_lines.ga_len = cctx->ctx_lnum + 1; + res = compile_expr0(&p, cctx); + var_start[varlen] = c; + cctx->ctx_ufunc->uf_lines.ga_len = lines_len; + if (res == FAIL || p != var_start + varlen) { // this should not happen - emsg(_(e_missbrac)); - var_start[varlen] = c; + if (res != FAIL) + emsg(_(e_missbrac)); return FAIL; } - var_start[varlen] = c; lhs->lhs_type = stack->ga_len == 0 ? &t_void : ((type_T **)stack->ga_data)[stack->ga_len - 1]; |