Mercurial > vim
changeset 18412:6208e5c2eee7 v8.1.2200
patch 8.1.2200: crash when memory allocation fails
Commit: https://github.com/vim/vim/commit/1cac70953d3c012453ea85b1308a8b1f94359c26
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 22 21:54:31 2019 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Oct 2019 22:00:05 +0200 |
parents | a100cc3da45a |
children | 90aa634b3bff |
files | src/getchar.c src/version.c |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/getchar.c +++ b/src/getchar.c @@ -2059,8 +2059,8 @@ f_getcharmod(typval_T *argvars UNUSED, t 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