To: vim_dev@googlegroups.com Subject: Patch 9.0.0547 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0547 Problem: Looping over empty out_loop[] entries. Solution: Store the array size. Files: src/structs.h, src/vim9execute.c *** ../vim-9.0.0546/src/structs.h 2022-09-21 18:59:10.671074961 +0100 --- src/structs.h 2022-09-22 16:24:31.542901045 +0100 *************** *** 2126,2131 **** --- 2126,2132 ---- // 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 *** ../vim-9.0.0546/src/vim9execute.c 2022-09-19 16:08:01.428998441 +0100 --- src/vim9execute.c 2022-09-22 16:35:12.585121112 +0100 *************** *** 1868,1874 **** --- 1868,1877 ---- 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,5752 **** 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 (current_ectx != NULL) { if (current_ectx->ec_outer_ref != NULL --- 5742,5751 ---- if (partial != NULL) { outer_T *outer = get_pt_outer(partial); ! 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 *** ../vim-9.0.0546/src/version.c 2022-09-22 16:11:47.281127583 +0100 --- src/version.c 2022-09-22 16:36:10.456961768 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 547, /**/ -- There are three kinds of persons: Those who can count and those who can't. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///