mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
unicode-combining: limit maximum number of allowed composed chains
This commit is contained in:
parent
1ebdc01162
commit
4d4df92f66
2 changed files with 13 additions and 5 deletions
|
|
@ -217,6 +217,7 @@ struct terminal {
|
|||
struct grid *grid;
|
||||
|
||||
#define COMB_CHARS_LO 0x40000000ul
|
||||
#define COMB_CHARS_HI 0x400ffffful
|
||||
size_t composed_count;
|
||||
struct composed *composed;
|
||||
|
||||
|
|
|
|||
17
vt.c
17
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue