Fix overflow panic in skipping_iterator_t with explicit saturating_add#397
Conversation
07216fc to
0220f2a
Compare
|
Not 100% sure if this is the right approach, but does help against issues with encountering overflows with AAT font shaping. |
|
If I understand the code correctly, this should simply be a uint and no saturation needed. In fact, the fact that it's 16bit is one of those beefs I have with this codebase baking a lot of gid16 assumptions around. |
|
I'd prefer to avoid machine-sized types like |
|
|
+1. Use of unnecessarily narrow types is endemic in this codebase and choosing promotion rather than truncation has been my strategy when I encounter these. |
0220f2a to
10bb9c5
Compare
When shaping extremely long lines with fonts that have classic `kern` or AAT `kerx` tables, the shaper instantiates a single `skipping_iterator_t` once outside the loop and reuses it across the entire buffer. Because `self.glyph_data` accumulates matching sequence indices without being reset, it can eventually exceed `u16::MAX` (65,535) and cause an addition overflow panic. This fix upgrades `self.glyph_data` to a `u32`, and propagates the type upgrade to match_func. Assisted-by: Gemini
10bb9c5 to
c262b3f
Compare
|
Upgraded to u32 and propagating this to |
When shaping extremely long lines with fonts that have classic
kernorAAT
kerxtables, the shaper instantiates a singleskipping_iterator_tonce outside the loop and reuses it across the entire buffer. Because
self.glyph_dataaccumulates matching sequence indices without being reset,it can eventually exceed
u16::MAX(65,535) and cause an additionoverflow panic.
This fix upgrades
self.glyph_datato au32, and propagates the typeupgrade to match_func.
Assisted-by: Gemini