0
0
mirror of https://github.com/vim/vim.git synced 2025-11-14 23:04:02 -05:00

patch 8.1.2200: crash when memory allocation fails

Problem:    Crash when memory allocation fails.
Solution:   Check for NULL curwin and curbuf. (Christian Brabandt,
            closes #4839)
This commit is contained in:
Bram Moolenaar
2019-10-22 21:54:31 +02:00
parent a720be78d7
commit 1cac70953d
2 changed files with 12 additions and 2 deletions

View File

@@ -2059,8 +2059,8 @@ f_getcharmod(typval_T *argvars UNUSED, typval_T *rettv)
void
parse_queued_messages(void)
{
int old_curwin_id = curwin->w_id;
int old_curbuf_fnum = curbuf->b_fnum;
int old_curwin_id;
int old_curbuf_fnum;
int i;
int save_may_garbage_collect = may_garbage_collect;
static int entered = 0;
@@ -2071,6 +2071,14 @@ parse_queued_messages(void)
if (updating_screen)
return;
// If memory allocation fails during startup we'll exit but curbuf or
// curwin could be NULL.
if (curbuf == NULL || curwin == NULL)
return;
old_curbuf_fnum = curbuf->b_fnum;
old_curwin_id = curwin->w_id;
++entered;
// may_garbage_collect is set in main_loop() to do garbage collection when