aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-05-03 09:31:59 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-05-03 09:31:59 +0000
commit4d4df92f661c6756cffd2ab6bc7983c3f1ced8c2 (patch)
tree14d141ed96f7e47a6adb6102a0ab1626cd125a29 /vt.c
parentunicode-combining: detect when we've reached the chain limit (diff)
unicode-combining: limit maximum number of allowed composed chains
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/vt.c b/vt.c
index 4ceaa25b..157f7a9c 100644
--- a/vt.c
+++ b/vt.c
@@ -681,12 +681,19 @@ action_utf8_print(struct terminal *term, uint8_t c)
new_cc.combining[i] = composed->combining[i];
new_cc.combining[wanted_count - 1] = wc;
- term->composed_count++;
- term->composed = realloc(term->composed, term->composed_count * sizeof(term->composed[0]));
- term->composed[term->composed_count - 1] = new_cc;
+ if (term->composed_count < COMB_CHARS_HI) {
+ term->composed_count++;
+ term->composed = realloc(term->composed, term->composed_count * sizeof(term->composed[0]));
+ term->composed[term->composed_count - 1] = new_cc;
- term_print(term, COMB_CHARS_LO + term->composed_count - 1, base_width);
- return;
+ term_print(term, COMB_CHARS_LO + term->composed_count - 1, base_width);
+ return;
+ } else {
+ /* We reached our maximum number of allowed composed
+ * character chains. Fall through here and print the
+ * current zero-width character to the current cell */
+ LOG_WARN("maximum number of composed characters reached");
+ }
}
}