Skip to content

Commit

Permalink
freetype: Early return if no contours.
Browse files Browse the repository at this point in the history
Fixes the Safety precondition
> `data must be non-null and aligned even for zero-length slices`
  • Loading branch information
jschwe committed May 9, 2024
1 parent d786ccc commit dd6d87e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/loaders/freetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ impl Font {
}

let outline = &(*(*self.freetype_face).glyph).outline;
if outline.n_contours == 0 {
return Ok(());
}
let contours = slice::from_raw_parts(outline.contours, outline.n_contours as usize);
let point_positions = slice::from_raw_parts(outline.points, outline.n_points as usize);
let point_tags = slice::from_raw_parts(outline.tags, outline.n_points as usize);
Expand Down

0 comments on commit dd6d87e

Please sign in to comment.