Mercurial > vim
comparison src/vim9execute.c @ 30423:221cca379bd5 v9.0.0547
patch 9.0.0547: looping over empty out_loop[] entries
Commit: https://github.com/vim/vim/commit/6d313bec535d9ccc24f6f82025280a61caad7416
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 22 16:36:25 2022 +0100
patch 9.0.0547: looping over empty out_loop[] entries
Problem: Looping over empty out_loop[] entries.
Solution: Store the array size.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 22 Sep 2022 17:45:03 +0200 |
parents | dac4fe437840 |
children | 4198995b9210 |
comparison
equal
deleted
inserted
replaced
30422:52b7188f13b1 | 30423:221cca379bd5 |
---|---|
1866 pt->pt_outer.out_loop[depth].var_idx = ectx->ec_frame_idx | 1866 pt->pt_outer.out_loop[depth].var_idx = ectx->ec_frame_idx |
1867 + STACK_FRAME_SIZE + lvi->lvi_loop[depth].var_idx; | 1867 + STACK_FRAME_SIZE + lvi->lvi_loop[depth].var_idx; |
1868 pt->pt_outer.out_loop[depth].var_count = | 1868 pt->pt_outer.out_loop[depth].var_count = |
1869 lvi->lvi_loop[depth].var_count; | 1869 lvi->lvi_loop[depth].var_count; |
1870 } | 1870 } |
1871 pt->pt_outer.out_loop_size = lvi->lvi_depth; | |
1871 } | 1872 } |
1873 else | |
1874 pt->pt_outer.out_loop_size = 0; | |
1872 | 1875 |
1873 // If the function currently executing returns and the closure is still | 1876 // If the function currently executing returns and the closure is still |
1874 // being referenced, we need to make a copy of the context (arguments | 1877 // being referenced, we need to make a copy of the context (arguments |
1875 // and local variables) so that the closure can use it later. | 1878 // and local variables) so that the closure can use it later. |
1876 // Store a reference to the partial so we can handle that. | 1879 // Store a reference to the partial so we can handle that. |
5737 if (ectx.ec_outer_ref == NULL) | 5740 if (ectx.ec_outer_ref == NULL) |
5738 goto failed_early; | 5741 goto failed_early; |
5739 if (partial != NULL) | 5742 if (partial != NULL) |
5740 { | 5743 { |
5741 outer_T *outer = get_pt_outer(partial); | 5744 outer_T *outer = get_pt_outer(partial); |
5742 int depth; | 5745 |
5743 void *ptr = outer->out_stack; | 5746 if (outer->out_stack == NULL && outer->out_loop_size == 0) |
5744 | 5747 { |
5745 // see if any stack was set | 5748 // no stack was set |
5746 for (depth = 0; ptr == NULL && depth < MAX_LOOP_DEPTH; ++depth) | |
5747 ptr = outer->out_loop[depth].stack; | |
5748 if (ptr == NULL) | |
5749 { | |
5750 if (current_ectx != NULL) | 5749 if (current_ectx != NULL) |
5751 { | 5750 { |
5752 if (current_ectx->ec_outer_ref != NULL | 5751 if (current_ectx->ec_outer_ref != NULL |
5753 && current_ectx->ec_outer_ref->or_outer != NULL) | 5752 && current_ectx->ec_outer_ref->or_outer != NULL) |
5754 ectx.ec_outer_ref->or_outer = | 5753 ectx.ec_outer_ref->or_outer = |