From f84850bae1a386b9d68713b88593232d04e13269 Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 9 May 2014 02:47:25 +0000 Subject: [PATCH] After entering an invalid three-letter card name, one letter card names stopped working because the third letter remained in the buffer, incard() skipped the NUL and used the old garbage. Fix this bug reported by pjanzen@, but in a simpler way than he suggested, by just clearing any trailing garbage from the buffer. ok pjanzen@ --- games/cribbage/io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/games/cribbage/io.c b/games/cribbage/io.c index 551c5c99386..3696d1878a0 100644 --- a/games/cribbage/io.c +++ b/games/cribbage/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.15 2014/05/09 00:03:41 schwarze Exp $ */ +/* $OpenBSD: io.c,v 1.16 2014/05/09 02:47:25 schwarze Exp $ */ /* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */ /*- @@ -552,7 +552,8 @@ get_line(void) Mpos++; } } - linebuf[pos] = '\0'; + while (pos < sizeof(linebuf)) + linebuf[pos++] = '\0'; stdscr = oscr; return (linebuf); } -- 2.20.1