diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-22 16:36:25 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-22 16:36:25 +0100 |
commit | 6d313bec535d9ccc24f6f82025280a61caad7416 (patch) | |
tree | 5b21870f647e33771fe1f2f14c20fd7af8925a71 | |
parent | 236ccbf6f8a671a45b773de4b34558ecfdf9ac02 (diff) | |
download | vim-git-6d313bec535d9ccc24f6f82025280a61caad7416.tar.gz |
patch 9.0.0547: looping over empty out_loop[] entriesv9.0.0547
Problem: Looping over empty out_loop[] entries.
Solution: Store the array size.
-rw-r--r-- | src/structs.h | 1 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9execute.c | 11 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/structs.h b/src/structs.h index 19dc55075..31889f6ef 100644 --- a/src/structs.h +++ b/src/structs.h @@ -2126,6 +2126,7 @@ struct outer_S { // out_loop_stack short var_count; // number of variables defined in a loop } out_loop[MAX_LOOP_DEPTH]; + int out_loop_size; // nr of used entries in out_loop[] }; struct partial_S diff --git a/src/version.c b/src/version.c index 4641a1fa8..2f36c39f3 100644 --- a/src/version.c +++ b/src/version.c @@ -700,6 +700,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 547, +/**/ 546, /**/ 545, diff --git a/src/vim9execute.c b/src/vim9execute.c index 51c5420bc..9416cf3a3 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -1868,7 +1868,10 @@ fill_partial_and_closure( pt->pt_outer.out_loop[depth].var_count = lvi->lvi_loop[depth].var_count; } + pt->pt_outer.out_loop_size = lvi->lvi_depth; } + else + pt->pt_outer.out_loop_size = 0; // If the function currently executing returns and the closure is still // being referenced, we need to make a copy of the context (arguments @@ -5739,14 +5742,10 @@ call_def_function( if (partial != NULL) { outer_T *outer = get_pt_outer(partial); - int depth; - void *ptr = outer->out_stack; - // see if any stack was set - for (depth = 0; ptr == NULL && depth < MAX_LOOP_DEPTH; ++depth) - ptr = outer->out_loop[depth].stack; - if (ptr == NULL) + if (outer->out_stack == NULL && outer->out_loop_size == 0) { + // no stack was set if (current_ectx != NULL) { if (current_ectx->ec_outer_ref != NULL |