comparison src/getchar.c @ 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 084b28fb3d22
children 9e6d5a4abb1c
comparison
equal deleted inserted replaced
18411:a100cc3da45a 18412:6208e5c2eee7
2057 * it is safe to do so. 2057 * it is safe to do so.
2058 */ 2058 */
2059 void 2059 void
2060 parse_queued_messages(void) 2060 parse_queued_messages(void)
2061 { 2061 {
2062 int old_curwin_id = curwin->w_id; 2062 int old_curwin_id;
2063 int old_curbuf_fnum = curbuf->b_fnum; 2063 int old_curbuf_fnum;
2064 int i; 2064 int i;
2065 int save_may_garbage_collect = may_garbage_collect; 2065 int save_may_garbage_collect = may_garbage_collect;
2066 static int entered = 0; 2066 static int entered = 0;
2067 int was_safe = get_was_safe_state(); 2067 int was_safe = get_was_safe_state();
2068 2068
2069 // Do not handle messages while redrawing, because it may cause buffers to 2069 // Do not handle messages while redrawing, because it may cause buffers to
2070 // change or be wiped while they are being redrawn. 2070 // change or be wiped while they are being redrawn.
2071 if (updating_screen) 2071 if (updating_screen)
2072 return; 2072 return;
2073
2074 // If memory allocation fails during startup we'll exit but curbuf or
2075 // curwin could be NULL.
2076 if (curbuf == NULL || curwin == NULL)
2077 return;
2078
2079 old_curbuf_fnum = curbuf->b_fnum;
2080 old_curwin_id = curwin->w_id;
2073 2081
2074 ++entered; 2082 ++entered;
2075 2083
2076 // may_garbage_collect is set in main_loop() to do garbage collection when 2084 // may_garbage_collect is set in main_loop() to do garbage collection when
2077 // blocking to wait on a character. We don't want that while parsing 2085 // blocking to wait on a character. We don't want that while parsing