mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
Do not hang in format_trim_* on invalid UTF-8 characters.
This commit is contained in:
parent
6628e542b5
commit
36eb16ce7d
@ -849,8 +849,10 @@ format_trim_left(const char *expanded, u_int limit)
|
|||||||
out += ud.size;
|
out += ud.size;
|
||||||
}
|
}
|
||||||
width += ud.width;
|
width += ud.width;
|
||||||
} else
|
} else {
|
||||||
cp -= ud.have;
|
cp -= ud.have;
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
} else if (*cp > 0x1f && *cp < 0x7f) {
|
} else if (*cp > 0x1f && *cp < 0x7f) {
|
||||||
if (width + 1 <= limit)
|
if (width + 1 <= limit)
|
||||||
*out++ = *cp;
|
*out++ = *cp;
|
||||||
@ -896,8 +898,10 @@ format_trim_right(const char *expanded, u_int limit)
|
|||||||
out += ud.size;
|
out += ud.size;
|
||||||
}
|
}
|
||||||
width += ud.width;
|
width += ud.width;
|
||||||
} else
|
} else {
|
||||||
cp -= ud.have;
|
cp -= ud.have;
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
} else if (*cp > 0x1f && *cp < 0x7f) {
|
} else if (*cp > 0x1f && *cp < 0x7f) {
|
||||||
if (width >= skip)
|
if (width >= skip)
|
||||||
*out++ = *cp;
|
*out++ = *cp;
|
||||||
|
Loading…
Reference in New Issue
Block a user