Skip to content

Commit

Permalink
Bail out from rendering when bitmap_buffer is null
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed May 24, 2023
1 parent 75f99cf commit 787b68f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/loaders/freetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,13 @@ impl Font {
let bitmap_size = Vector2I::new(bitmap_width, bitmap_height);
let bitmap_buffer = (*bitmap).buffer as *const i8 as *const u8;
let bitmap_length = bitmap_stride * bitmap_height as usize;
if bitmap_buffer.is_null() {
assert_eq!(
bitmap_length, 0,
"bitmap length should be 0 when bitmap_buffer is nullptr"
);
return Ok(());
}
let buffer = slice::from_raw_parts(bitmap_buffer, bitmap_length);
let dst_point = Vector2I::new(
(*(*self.freetype_face).glyph).bitmap_left,
Expand Down

0 comments on commit 787b68f

Please sign in to comment.