1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +02:00

Fix saturating overflow in ExtraData parsing

- Fix overflow in ExtraData by casting byte_len to usize before
multiplication. This was previously multiplying a u16 with
saturating_mul and would overflow when the extra data in string
tables reaches a certain size.
- Add test case for parsing large string table to verify correct
stream position after read.
This commit is contained in:
glyphpoch 2025-06-02 21:24:00 +01:00
commit 624efb6427
4 changed files with 26 additions and 2 deletions

View file

@ -154,7 +154,7 @@ fn test_string_table_roundtrip() {
#[serde(bound(deserialize = "'a: 'static"))]
pub struct ExtraData<'a> {
pub byte_len: u16,
#[size = "byte_len.saturating_mul(8)"]
#[size = "(byte_len as usize).saturating_mul(8)"]
pub data: Stream<'a>,
}