commit 9ce41543ed5847697263bf148326e15590a1afce
parent e4775c206071644c943a88ce6398748ab6957752
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 18 May 2017 10:16:52 +0200
startup: don't call delwin() with NULL, to avoid crashing on Solaris
Apparently the curses on SunOS is less forgiving than the one on GNU.
Or rather: delwin(NULL) should just return an error, it shouldn't crash.
This fixes https://savannah.gnu.org/bugs/?51053.
Reported-by: John Wiersba <jrw32982@yahoo.com>
Solved-by: John Wiersba <jrw32982@yahoo.com>
Diffstat:
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git 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
@@ -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. */