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.
This commit is contained in:
Daniel Eklöf 2020-05-03 11:27:06 +02:00
parent b7ad4c2e2a
commit 1ebdc01162
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

14
vt.c
View file

@ -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++) {