From baa266ff5568862d25f6cd8b7807e8e226029b8d Mon Sep 17 00:00:00 2001 From: Riccardo Zaglia Date: Sun, 15 Sep 2024 23:00:40 +0200 Subject: [PATCH] Fix UB in `Instance::supports_()` --- openxr/src/instance.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openxr/src/instance.rs b/openxr/src/instance.rs index e5f3417..06a7f24 100644 --- a/openxr/src/instance.rs +++ b/openxr/src/instance.rs @@ -151,6 +151,9 @@ impl Instance { #[inline] pub fn supports_render_model_loading(&self, system: SystemId) -> Result { + if self.exts().fb_render_model.is_none() { + return Err(sys::Result::ERROR_EXTENSION_NOT_PRESENT); + } unsafe { let mut render_model = sys::SystemRenderModelPropertiesFB::out(ptr::null_mut()); let mut p = sys::SystemProperties::out(&mut render_model as *mut _ as _); @@ -168,6 +171,9 @@ impl Instance { #[inline] pub fn supports_hand_tracking(&self, system: SystemId) -> Result { + if self.exts().ext_hand_interaction.is_none() { + return Err(sys::Result::ERROR_EXTENSION_NOT_PRESENT); + } unsafe { let mut hand = sys::SystemHandTrackingPropertiesEXT::out(ptr::null_mut()); let mut p = sys::SystemProperties::out(&mut hand as *mut _ as _);