]> granicus.if.org Git - nethack/commitdiff
debian #184911 - quitting while tty mode inventory is displayed
authorcohrs <cohrs>
Tue, 14 Oct 2003 07:35:01 +0000 (07:35 +0000)
committercohrs <cohrs>
Tue, 14 Oct 2003 07:35:01 +0000 (07:35 +0000)
The tty menu code wasn't totally reentrant, causing it to free memory
that wasn't on the heap if you had your inventory displayed, ^C then
ask to see the inventory again.  Solved this by converting the buffer used
by process_menu_window to be heap-allocated.  If the Quit code could return at
this point, this would still be very bad, but since it doesn't, this is OK.

doc/fixes34.3
win/tty/wintty.c

index cf16a121bff9df0ed8fd0c3037dc7f9e51466070..e0f32a445de454f5be3bff93a884825df97759ed 100644 (file)
@@ -63,6 +63,7 @@ X11: avoid a possible crash when using window manger to close a player
        selection window
 Gnome: add Quiver menu item, fix outdated Quit menu item
 Gnome: key values on unsigned char platform could fail to compare correctly
+tty: avoid crash displaying quit inventory if inventory was already displayed
 
 
 General New Features
index 87a1a1c66da9692c1e6f03dd55bd768c4e089c70..e51dcb89398edfb27cac68c640e3445ee0095408 100644 (file)
@@ -1140,12 +1140,12 @@ struct WinDesc *cw;
     int n, curr_page, page_lines;
     boolean finished, counting, reset_count;
     char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ],
-        *msave, morestr[QBUFSZ];
+        *msave, *morestr;
 
     curr_page = page_lines = 0;
     page_start = page_end = 0;
     msave = cw->morestr;       /* save the morestr */
-    cw->morestr = morestr;
+    cw->morestr = morestr = (char*) alloc((unsigned) QBUFSZ);
     counting = FALSE;
     count = 0L;
     reset_count = TRUE;
@@ -1429,6 +1429,7 @@ struct WinDesc *cw;
 
     } /* while */
     cw->morestr = msave;
+    free((genericptr_t)morestr);
 }
 
 STATIC_OVL void