0afb3b8
From 8e6dfd53321a0b0047f7d75db21a946c166c600b Mon Sep 17 00:00:00 2001
0afb3b8
From: Christos Zoulas <christos@zoulas.com>
0afb3b8
Date: Fri, 17 Feb 2017 11:17:27 -0500
0afb3b8
Subject: [PATCH] Unfortunately the AsciiOnly reversion causes a SEGV because
0afb3b8
 *ch is used to index in the command array, and now contains INVALID_BYTE. env
0afb3b8
 -i ./tcsh <meta>b
0afb3b8
0afb3b8
---
0afb3b8
 ed.inputl.c | 18 +++++++++++-------
0afb3b8
 1 file changed, 11 insertions(+), 7 deletions(-)
0afb3b8
0afb3b8
diff --git a/ed.inputl.c b/ed.inputl.c
0afb3b8
index f543a6f..1a0d356 100644
0afb3b8
--- a/ed.inputl.c
0afb3b8
+++ b/ed.inputl.c
0afb3b8
@@ -796,13 +796,17 @@ GetNextChar(Char *cp)
0afb3b8
 		return -1;
0afb3b8
 	    }
0afb3b8
 	}
0afb3b8
-	cbp++;
0afb3b8
-	if (normal_mbtowc(cp, cbuf, cbp) == -1) {
0afb3b8
-	    reset_mbtowc();
0afb3b8
-	    if (cbp < MB_CUR_MAX)
0afb3b8
-		continue; /* Maybe a partial character */
0afb3b8
-	    /* And drop the following bytes, if any */
0afb3b8
-	    *cp = (unsigned char)*cbuf | INVALID_BYTE;
0afb3b8
+	if (AsciiOnly) {
0afb3b8
+	    *cp = (unsigned char)*cbuf;
0afb3b8
+	} else {
0afb3b8
+	    cbp++;
0afb3b8
+	    if (normal_mbtowc(cp, cbuf, cbp) == -1) {
0afb3b8
+		reset_mbtowc();
0afb3b8
+		if (cbp < MB_CUR_MAX)
0afb3b8
+		    continue; /* Maybe a partial character */
0afb3b8
+		/* And drop the following bytes, if any */
0afb3b8
+		*cp = (unsigned char)*cbuf | INVALID_BYTE;
0afb3b8
+	    }
0afb3b8
 	}
0afb3b8
 	break;
0afb3b8
     }
0afb3b8
-- 
0afb3b8
2.9.3
0afb3b8