Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skrifa] tthint: adjust DELTAP/DELTAC limits #1353

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions skrifa/src/outline/glyf/hint/engine/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ impl Engine<'_> {
let ppem = gs.ppem as u32;
let point_count = gs.zp0().points.len();
let n = self.value_stack.pop_count_checked()?;
// Additionally limit n to the number of points in zp0 since
// we don't expect to modify a point more than once
let n = n.min(point_count);
// Each exception requires two values on the stack so limit our
// count to prevent looping in non-pedantic mode (where the stack ops
// will produce 0 instead of an underflow error)
let n = n.min(self.value_stack.len() / 2);
let bias = match opcode {
Opcode::DELTAP2 => 16,
Opcode::DELTAP3 => 32,
Expand Down Expand Up @@ -98,9 +99,10 @@ impl Engine<'_> {
let gs = &mut self.graphics;
let ppem = gs.ppem as u32;
let n = self.value_stack.pop_count_checked()?;
// Additionally limit n to the number of CVT entries since we
// don't expect to modify an entry more than once
let n = n.min(self.cvt.len());
// Each exception requires two values on the stack so limit our
// count to prevent looping in non-pedantic mode (where the stack ops
// will produce 0 instead of an underflow error)
let n = n.min(self.value_stack.len() / 2);
let bias = match opcode {
Opcode::DELTAC2 => 16,
Opcode::DELTAC3 => 32,
Expand Down