aboutsummaryrefslogtreecommitdiffstats
path: root/libwc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libwc/wtf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libwc/wtf.c b/libwc/wtf.c
index b8cfdc7..69a8271 100644
--- a/libwc/wtf.c
+++ b/libwc/wtf.c
@@ -120,10 +120,14 @@ int
wtf_strwidth(wc_uchar *p)
{
int w = 0;
+ size_t len;
while (*p) {
w += wtf_width(p);
- p += WTF_LEN_MAP[*p];
+ len = WTF_LEN_MAP[*p];
+ if (len > strlen(p))
+ len = strlen(p);
+ p += len;
}
return w;
}