From 3ce6b720ac3121f63ebb693d744646a94d92d91c Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 6 Mar 2025 04:09:49 +0200 Subject: [PATCH] [fontations] slice::from_raw_parts requires the pointer to be non-null --- src/fontations/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fontations/lib.rs b/src/fontations/lib.rs index 37af3a1db..17f88f89b 100644 --- a/src/fontations/lib.rs +++ b/src/fontations/lib.rs @@ -776,7 +776,11 @@ pub extern "C" fn hb_fontations_font_set_funcs(font: *mut hb_font_t) { let mut num_coords: u32 = 0; let coords = unsafe { hb_font_get_var_coords_normalized(font, &mut num_coords) }; - let coords = unsafe { std::slice::from_raw_parts(coords, num_coords as usize) }; + let coords = if coords.is_null() { + &[] + } else { + unsafe { std::slice::from_raw_parts(coords, num_coords as usize) } + }; let all_zeros = coords.iter().all(|&x| x == 0); // if all zeros, use Location::default() // otherwise, use the provided coords.