]> granicus.if.org Git - nethack/commitdiff
Fix TTY crashing when a location has more than 32k items
authorPasi Kallinen <paxed@alt.org>
Mon, 2 Mar 2015 18:34:25 +0000 (20:34 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 2 Mar 2015 18:34:25 +0000 (20:34 +0200)
include/wintty.h
win/tty/wintty.c

index 507804a9f982da93ef499376fb04018754469aec..76007ed3fc65eba5c76880cdc9d241f0d6eba145 100644 (file)
@@ -29,9 +29,9 @@ struct WinDesc {
     xchar type;                        /* type of window */
     boolean active;            /* true if window is active */
     short offx, offy;          /* offset from topleft of display */
-    short rows, cols;          /* dimensions */
-    short curx, cury;          /* current cursor position */
-    short maxrow, maxcol;      /* the maximum size used -- for MENU wins */
+    long rows, cols;           /* dimensions */
+    long curx, cury;           /* current cursor position */
+    long maxrow, maxcol;       /* the maximum size used -- for MENU wins */
                                /* maxcol is also used by WIN_MESSAGE for */
                                /* tracking the ^P command */
     short *datlen;             /* allocation size for *data */
@@ -39,9 +39,9 @@ struct WinDesc {
     char *morestr;             /* string to display instead of default */
     tty_menu_item *mlist;      /* menu information (MENU) */
     tty_menu_item **plist;     /* menu page pointers (MENU) */
-    short plist_size;          /* size of allocated plist (MENU) */
-    short npages;              /* number of pages in menu (MENU) */
-    short nitems;              /* total number of items (MENU) */
+    long plist_size;           /* size of allocated plist (MENU) */
+    long npages;               /* number of pages in menu (MENU) */
+    long nitems;               /* total number of items (MENU) */
     short how;                 /* menu mode - pick 1 or N (MENU) */
     char menu_ch;              /* menu char (MENU) */
 };
index a526897b734515d5fcea600d64856611cf1b4216..67b0243d4d2495124fe92bb742a6927dd222a435 100644 (file)
@@ -1997,7 +1997,7 @@ tty_putstr(window, attr, str)
     register struct WinDesc *cw = 0;
     register char *ob;
     register const char *nb;
-    register int i, j, n0;
+    register long i, j, n0;
 
     /* Assume there's a real problem if the window is missing --
      * probably a panic message
@@ -2375,7 +2375,7 @@ tty_end_menu(window, prompt)
     if (cw->npages > 1) {
        char buf[QBUFSZ];
        /* produce the largest demo string */
-       Sprintf(buf, "(%d of %d) ", cw->npages, cw->npages);
+       Sprintf(buf, "(%ld of %ld) ", cw->npages, cw->npages);
        len = strlen(buf);
        cw->morestr = copy_of("");
     } else {