diff --git a/src/search.c b/src/search.c
index e86b20b85e01358b53d45baf93167ee2494b03e9..5edeb022dacb01fc12c0d88d7a5c162b4f55df39 100644
--- a/src/search.c
+++ b/src/search.c
@@ -219,7 +219,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
 			lastkbcheck = time(NULL);
 
 			/* Consume all waiting keystrokes until a Cancel. */
-			while (input) {
+			while (input != ERR) {
 				if (func_from_key(&input) == do_cancel) {
 					statusbar(_("Cancelled"));
 					enable_waiting();
diff --git a/src/winio.c b/src/winio.c
index b1488d5b337fcdbcb740afab86d0c1376dcb5197..7e338757a9d877e7217d95f53ec12df2a81d26b3 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -363,7 +363,7 @@ int parse_kbinput(WINDOW *win)
 	kbinput = get_input(win, 1);
 
 	if (kbinput == NULL && !waiting_mode)
-		return 0;
+		return ERR;
 
 	while (kbinput == NULL)
 		kbinput = get_input(win, 1);