aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-05-03 09:27:06 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-05-03 09:27:06 +0000
commit1ebdc0116263c2ac8f5b4de98c8bfe0aa768480b (patch)
treebbb2f0ce4dcc61158d677ec53b2a70657e39e18a
parentchangelog: update 'unicode comining' entry - only parts of the feature are optional (diff)
unicode-combining: detect when we've reached the chain limit
We currently store up to 5 combining characters in any given base+combining chain. This adds a check for when that limit is about to be exceeded. When this happens, we log the chain + the new combining character. Since things will break anyway, we simply overwrite the last combining character.
-rw-r--r--vt.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/vt.c b/vt.c
index 74110eb6..4ceaa25b 100644
--- a/vt.c
+++ b/vt.c
@@ -641,6 +641,20 @@ action_utf8_print(struct terminal *term, uint8_t c)
#endif
size_t wanted_count = composed != NULL ? composed->count + 1 : 1;
+ if (wanted_count > ALEN(composed->combining)) {
+ assert(composed != NULL);
+
+ LOG_WARN("combining character overflow:");
+ LOG_WARN(" base: 0x%04x", composed->base);
+ for (size_t i = 0; i < composed->count; i++)
+ LOG_WARN(" cc: 0x%04x", composed->combining[i]);
+ LOG_ERR(" new: 0x%04x", wc);
+
+ /* This are going to break anyway... */
+ wanted_count--;
+ }
+
+ assert(wanted_count <= ALEN(composed->combining));
/* Look for existing combining chain */
for (size_t i = 0; i < term->composed_count; i++) {