From 354597f0c252177608f34a37a1900d396c8ed33e Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 24 Mar 2006 16:04:44 +0000
Subject: [PATCH] in get_get_buffer(), die gracefully if input fails
 MAX_BUF_SIZE times, not (MAX_BUF_SIZE + 1) times

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3321 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 4 ++--
 src/winio.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 93896a54..bc673729 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,8 +62,8 @@ CVS code -
 	  matches the manual page. (DLR)
 - winio.c:
   get_key_buffer()
-	- If we fail to get a character over MAX_BUF_SIZE times in a
-	  row, hang up regardless of the value of errno.  This fixes a
+	- If we fail to get a character MAX_BUF_SIZE times in a row,
+	  hang up regardless of the value of errno.  This fixes a
 	  problem where nano doesn't terminate properly under xterm if
 	  the user su's to root, runs nano, and then closes the terminal
 	  window.  errno isn't set properly to EIO then. (DLR, found by
diff --git a/src/winio.c b/src/winio.c
index 71a3358d..aaab4072 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -141,12 +141,12 @@ void get_key_buffer(WINDOW *win)
     while ((input = wgetch(win)) == ERR) {
 	errcount++;
 
-	/* If we've failed to get a character over MAX_BUF_SIZE times in
-	 * a row, assume that the input source we were using is gone and
+	/* If we've failed to get a character MAX_BUF_SIZE times in a
+	 * row, assume that the input source we were using is gone and
 	 * die gracefully.  We could check if errno is set to EIO
 	 * ("Input/output error") and die gracefully in that case, but
 	 * it's not always set properly.  Argh. */
-	if (errcount > MAX_BUF_SIZE)
+	if (errcount == MAX_BUF_SIZE)
 	    handle_hupterm(0);
     }
 
-- 
GitLab