vim-patch:8.1.1591: on error garbage collection may free memory in use

Problem:    On error garbage collection may free memory in use.
Solution:   Reset may_garbage_collect when evaluating expression mapping.
            Add tests. (Ozaki Kiichi, closes vim/vim#4579)
7d491c4253
This commit is contained in:
Jan Edmund Lazo
2020-09-26 12:03:20 -04:00
parent 7cb38d5ac4
commit 4edf7b9ff2
4 changed files with 78 additions and 2 deletions

View File

@@ -2044,14 +2044,19 @@ static int vgetorpeek(bool advance)
*/
if (mp->m_expr) {
int save_vgetc_busy = vgetc_busy;
const bool save_may_garbage_collect = may_garbage_collect;
vgetc_busy = 0;
may_garbage_collect = false;
save_m_keys = vim_strsave(mp->m_keys);
save_m_str = vim_strsave(mp->m_str);
s = eval_map_expr(save_m_str, NUL);
vgetc_busy = save_vgetc_busy;
} else
may_garbage_collect = save_may_garbage_collect;
} else {
s = mp->m_str;
}
/*
* Insert the 'to' part in the typebuf.tb_buf.