diff options
author | nicm <nicm> | 2020-01-08 14:40:52 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-01-08 14:40:52 +0000 |
commit | 36eb16ce7db2db71b510964a2e453e6b349b03f0 (patch) | |
tree | 1385a410bb4e67d463b476dc6bc83a2fd98679e3 /format-draw.c | |
parent | 6628e542b5a0fabbd02800e68d19aecaf530fece (diff) | |
download | rtmux-36eb16ce7db2db71b510964a2e453e6b349b03f0.tar.gz rtmux-36eb16ce7db2db71b510964a2e453e6b349b03f0.tar.bz2 rtmux-36eb16ce7db2db71b510964a2e453e6b349b03f0.zip |
Do not hang in format_trim_* on invalid UTF-8 characters.
Diffstat (limited to 'format-draw.c')
-rw-r--r-- | format-draw.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/format-draw.c b/format-draw.c index 6cced9fd..bb16e0dd 100644 --- a/format-draw.c +++ b/format-draw.c @@ -849,8 +849,10 @@ format_trim_left(const char *expanded, u_int limit) out += ud.size; } width += ud.width; - } else + } else { cp -= ud.have; + cp++; + } } else if (*cp > 0x1f && *cp < 0x7f) { if (width + 1 <= limit) *out++ = *cp; @@ -896,8 +898,10 @@ format_trim_right(const char *expanded, u_int limit) out += ud.size; } width += ud.width; - } else + } else { cp -= ud.have; + cp++; + } } else if (*cp > 0x1f && *cp < 0x7f) { if (width >= skip) *out++ = *cp; |