]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0547: looping over empty out_loop[] entries v9.0.0547
authorBram Moolenaar <Bram@vim.org>
Thu, 22 Sep 2022 15:36:25 +0000 (16:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 22 Sep 2022 15:36:25 +0000 (16:36 +0100)
Problem:    Looping over empty out_loop[] entries.
Solution:   Store the array size.

src/structs.h
src/version.c
src/vim9execute.c

index 19dc5507513999cb169c90f1a5ea364f2cfc2d6b..31889f6ef64c5181a1005cba2ef861ef2811cfdf 100644 (file)
@@ -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
index 4641a1fa87244913e0883f2c03e6073604cb9225..2f36c39f38d6fe835d46b3cdebe7bb91b3ac804f 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    547,
 /**/
     546,
 /**/
index 51c5420bcd3a4a15f4139597d19e9bf8c2233142..9416cf3a35ad13fd378c7e3096ddabc1af62b3ba 100644 (file)
@@ -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