diff --git a/src/global.c b/src/global.c index 9cfabb98d21c34421eab7a753aa677eb048fe9f7..66a1f2e43763d3b79801d6e0f65d6cd6c8abf156 100644 --- a/src/global.c +++ b/src/global.c @@ -95,14 +95,14 @@ char *present_path = NULL; unsigned flags[4] = {0, 0, 0, 0}; /* Our flag containing the states of all global options. */ -WINDOW *topwin; +WINDOW *topwin = NULL; /* The top portion of the window, where we display the version * number of nano, the name of the current file, and whether the * current file has been modified. */ -WINDOW *edit; +WINDOW *edit = NULL; /* The middle portion of the window, i.e. the edit window, where * we display the current file we're editing. */ -WINDOW *bottomwin; +WINDOW *bottomwin = NULL; /* The bottom portion of the window, where we display statusbar * messages, the statusbar prompt, and a list of shortcuts. */ int editwinrows = 0; @@ -1728,7 +1728,8 @@ int strtomenu(const char *input) * function unless debugging is turned on. */ void thanks_for_all_the_fish(void) { - delwin(topwin); + if (topwin != NULL) + delwin(topwin); delwin(edit); delwin(bottomwin); diff --git a/src/nano.c b/src/nano.c index 28ec1e09794734b1519b882498d95be9dc3a1e59..9a6580d11e4b02f9dc7171975e9c3ebb175c2d51 100644 --- a/src/nano.c +++ b/src/nano.c @@ -677,14 +677,17 @@ void die_save_file(const char *die_filename, struct stat *die_stat) /* Initialize the three window portions nano uses. */ void window_init(void) { - /* First delete existing windows, in case of resizing. */ - delwin(topwin); - topwin = NULL; - delwin(edit); - delwin(bottomwin); + /* When resizing, first delete the existing windows. */ + if (edit != NULL) { + if (topwin != NULL) + delwin(topwin); + delwin(edit); + delwin(bottomwin); + } /* If the terminal is very flat, don't set up a titlebar. */ if (LINES < 3) { + topwin = NULL; editwinrows = 1; /* Set up two subwindows. If the terminal is just one line, * edit window and statusbar window will cover each other. */