Browse Source

Bugfix: segmentation fault if the terminal window is too narrow for the Help and Quit items

Nate Woolls 12 years ago
parent
commit
b8f2a9f5c1
1 changed files with 5 additions and 0 deletions
  1. 5 0
      miner.c

+ 5 - 0
miner.c

@@ -3622,6 +3622,11 @@ void bfg_wspctoeol(WINDOW * const win, const int offset)
 	getmaxyx(win, y, maxx);
 	getmaxyx(win, y, maxx);
 	getyx(win, y, x);
 	getyx(win, y, x);
 	const int space_count = (maxx - x) - offset;
 	const int space_count = (maxx - x) - offset;
+	
+	// Check for negative - terminal too narrow
+	if (space_count <= 0)
+		return;
+	
 	char buf[space_count];
 	char buf[space_count];
 	memset(buf, ' ', space_count);
 	memset(buf, ' ', space_count);
 	waddnstr(win, buf, space_count);
 	waddnstr(win, buf, space_count);