Skip to content

Commit

Permalink
Bail out gracefully on malformed kern table headers.
Browse files Browse the repository at this point in the history
Fixes #12081.
  • Loading branch information
mbrubeck committed Jul 6, 2016
1 parent 4aaae7a commit 5582fcc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/gfx/platform/macos/font.rs
Expand Up @@ -113,11 +113,14 @@ impl FontHandle {
let pair_data_start = subtable_start + FORMAT_0_HEADER_LEN;

result.pair_data_range = pair_data_start..end;
if result.pair_data_range.len() != n_pairs * KERN_PAIR_LEN {
debug!("Bad data in kern header. Disable fast path.");
return None;
}

let pt_per_font_unit = self.ctfont.pt_size() as f64 /
self.ctfont.units_per_em() as f64;
result.px_per_font_unit = pt_to_px(pt_per_font_unit);

debug_assert_eq!(n_pairs * KERN_PAIR_LEN, result.pair_data_range.len());
}
start = end;
}
Expand Down

0 comments on commit 5582fcc

Please sign in to comment.