aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libwc/wtf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libwc/wtf.c b/libwc/wtf.c
index 9a9a15c..7d450a1 100644
--- a/libwc/wtf.c
+++ b/libwc/wtf.c
@@ -141,9 +141,10 @@ size_t
wtf_len(wc_uchar *p)
{
wc_uchar *q = p;
+ wc_uchar *strz = p + strlen(p);
q += WTF_LEN_MAP[*q];
- while (*q && ! WTF_WIDTH_MAP[*q])
+ while (q < strz && ! WTF_WIDTH_MAP[*q])
q += WTF_LEN_MAP[*q];
return q - p;
}