Commit Diff


commit - a727811a2c15ab09685d897dcc098d92052bb396
commit + 2b03bf696ca055900ba587d010e731964f56ee3a
blob - f87a310b425ac1179fb2dd8b0b0cb418b7c8736c
blob + 4045332de80f1c5fcac9aa17bdbbbac05a1dc337
--- src/cmd/tcs/utf.c
+++ src/cmd/tcs/utf.c
@@ -45,7 +45,7 @@ utf_in(int fd, long *notused, struct convert *out)
 	tot = 0;
 	while((n = read(fd, buf+tot, N-tot)) >= 0){
 		tot += n;
-		for(i=j=0; i<tot-UTFmax || (n==0 && i<tot); ){
+		for(i=j=0; i<=tot-UTFmax || (i<tot && (n==0 || fullrune(buf+i, tot-i))); ){
 			c = our_mbtowc(&l, buf+i, tot-i);
 			if(c == -1){
 				if(squawk)