string-util: add missing assertion in cellescape

This commit is contained in:
Mike Yuan
2024-04-03 23:00:55 +08:00
parent 1c6ca6d924
commit 596c9e671a

View File

@@ -562,7 +562,9 @@ char *cellescape(char *buf, size_t len, const char *s) {
size_t i = 0, last_char_width[4] = {}, k = 0;
assert(buf);
assert(len > 0); /* at least a terminating NUL */
assert(s);
for (;;) {
char four[4];
@@ -612,7 +614,7 @@ char *cellescape(char *buf, size_t len, const char *s) {
else
assert(i + 1 <= len);
done:
done:
buf[i] = '\0';
return buf;
}