Skip to content

Commit

Permalink
[read-fonts] Fix possible crash in PackedPointNumbersIter
Browse files Browse the repository at this point in the history
This would only be encountered if the user manually tried to iterate
packed points with a single 0x0 byte (signifying that there are points
for all deltas) and did not also know how many points there were; but
there's no reason not to be more careful here and at least stop
iterating after u16::MAX items.
  • Loading branch information
cmyr committed Sep 26, 2023
1 parent f8a8ccf commit 49399ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion read-fonts/src/tables/variations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl Iterator for PackedPointNumbersIter<'_> {
// if our count is zero, we keep incrementing forever
if self.count == 0 {
let result = self.last_val;
self.last_val += 1;
self.last_val = self.last_val.checked_add(1)?;
return Some(result);
}

Expand Down

0 comments on commit 49399ae

Please sign in to comment.