summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-22 21:54:31 +0200
committerBram Moolenaar <Bram@vim.org>2019-10-22 21:54:31 +0200
commit1cac70953d3c012453ea85b1308a8b1f94359c26 (patch)
treef950c729773df35a13d07a2b1edc7637c45a699c /src
parenta720be78d7978b3b853ff6c8af0d1721d6225378 (diff)
downloadvim-git-1cac70953d3c012453ea85b1308a8b1f94359c26.tar.gz
patch 8.1.2200: crash when memory allocation failsv8.1.2200
Problem: Crash when memory allocation fails. Solution: Check for NULL curwin and curbuf. (Christian Brabandt, closes #4839)
Diffstat (limited to 'src')
-rw-r--r--src/getchar.c12
-rw-r--r--src/version.c2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/getchar.c b/src/getchar.c
index f9bfab829..07383da2c 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -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
diff --git a/src/version.c b/src/version.c
index f6e0b76e6..60a690dec 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2200,
+/**/
2199,
/**/
2198,