[PATCH] terminal: Don't crash on non-ascii chars

Andre Heider a.heider at gmail.com
Thu Aug 2 11:59:43 PDT 2012


isalpha() and isdigit() don't like huge values.
Noticed with ascii-art in the shell prompt.
---
 clients/terminal.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/clients/terminal.c b/clients/terminal.c
index dd35ceb..cbcd1ec 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -2266,6 +2266,9 @@ static int wordsep(int ch)
 {
 	const char extra[] = "-,./?%&#:_=+@~";
 
+	if (ch > 127)
+		return 1;
+
 	return ch == 0 || !(isalpha(ch) || isdigit(ch) || strchr(extra, ch));
 }
 
-- 
1.7.10.4



More information about the wayland-devel mailing list