Skip to content

Commit d8af4f7

Browse files
committed
Fix potential panic for malformed hhea table
1 parent fe7a0a2 commit d8af4f7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/hmtx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn subset(ctx: &mut Context) -> Result<()> {
6060

6161
let hhea = ctx.expect_table(Tag::HHEA).ok_or(MalformedFont)?;
6262
let mut sub_hhea = Writer::new();
63-
sub_hhea.extend(&hhea[0..hhea.len() - 2]);
63+
sub_hhea.extend(hhea.get(..hhea.len() - 2).ok_or(MalformedFont)?);
6464
sub_hhea.write::<u16>(last_advance_width_index + 1);
6565

6666
ctx.push(Tag::HHEA, sub_hhea.finish());

0 commit comments

Comments
 (0)