Skip to content

Commit

Permalink
patch 9.0.0547: looping over empty out_loop[] entries
Browse files Browse the repository at this point in the history
Problem:    Looping over empty out_loop[] entries.
Solution:   Store the array size.
  • Loading branch information
brammool committed Sep 22, 2022
1 parent 236ccbf commit 6d313be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
547,
/**/
546,
/**/
Expand Down
11 changes: 5 additions & 6 deletions src/vim9execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6d313be

Please sign in to comment.