]> granicus.if.org Git - nethack/commitdiff
Fix buffer underrun in curses
authorPasi Kallinen <paxed@alt.org>
Sun, 15 Nov 2020 11:22:45 +0000 (13:22 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 15 Nov 2020 11:22:45 +0000 (13:22 +0200)
win/curses/cursmisc.c

index 825df06a7488abe94be735e9b3bd3db4cc978bcd..0914400ea9703372d7b4cff0a8601f0b40c6155b 100644 (file)
@@ -691,7 +691,8 @@ curses_rtrim(char *str)
     char *s;
 
     for (s = str; *s != '\0'; ++s);
-    for (--s; isspace(*s) && s > str; --s);
+    if (s > str)
+        for (--s; isspace(*s) && s > str; --s);
     if (s == str)
         *s = '\0';
     else