From e0cef46e9c0fe6f4d45ac19a2ddaa74a33a5570e Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 22 Mar 2019 00:25:05 +0100 Subject: Make sure user input can be cancelled properly --- src/common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/common.c') diff --git a/src/common.c b/src/common.c index d4b7c8d..79dc123 100644 --- a/src/common.c +++ b/src/common.c @@ -527,7 +527,7 @@ void get_user_input(char *buf, int maxlen, int secure) int len = 0; int c; - while ((c = my_getch())) { + while ((c = my_getch()) > 0) { if ((c == '\r') || (c == '\n')) { break; } else if (isprint(c)) { @@ -541,6 +541,9 @@ void get_user_input(char *buf, int maxlen, int secure) } } } + if (c < 0) { + len = 0; + } fputs("\n", stdout); buf[len] = 0; } -- cgit v1.1-32-gdbae