summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mscan.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mscan.c b/mscan.c
index ae4fe35..c9a00a4 100644
--- a/mscan.c
+++ b/mscan.c
@@ -56,7 +56,10 @@ u8putstr(FILE *out, char *s, ssize_t l, int pad)
 				l--;
 				fprintf(out, "%lc", (wint_t)replacement);
 			} else {
-				l -= wcwidth((wchar_t)c);
+				int w = wcwidth((wchar_t)c);
+				if (w < 0)
+					w = 2;   /* assume worst width */
+				l -= w;
 				if (l >= 0)
 					fwrite(s, 1, r, out);
 			}