]> granicus.if.org Git - nethack/commitdiff
Fix underflow in free_window_info
authorBrian Campbell <Brian.Campbell@ed.ac.uk>
Sun, 26 Jun 2022 14:30:58 +0000 (15:30 +0100)
committerBrian Campbell <Brian.Campbell@ed.ac.uk>
Sun, 26 Jun 2022 14:30:58 +0000 (15:30 +0100)
At the end this is called after `WIN_MESSAGE` is reset to `-1`, so we
need a check here.

win/tty/wintty.c

index 0b5225c693017a19287202d339a4c42a76bf3786..76443417eb1fa8768c58c0dbc5b9f34e506f0190 100644 (file)
@@ -1769,7 +1769,8 @@ free_window_info(struct WinDesc *cw, boolean free_data)
     int i;
 
     if (cw->data) {
-        if (cw == wins[WIN_MESSAGE] && cw->rows > cw->maxrow)
+        if (WIN_MESSAGE != WIN_ERR && cw == wins[WIN_MESSAGE]
+            && cw->rows > cw->maxrow)
             cw->maxrow = cw->rows; /* topl data */
         for (i = 0; i < cw->maxrow; i++)
             if (cw->data[i]) {