From 0940e1f6352363cf2c3501bfa2cd182414688a47 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Tue, 4 Jun 2024 07:58:46 -0700 Subject: [PATCH] Check for null pointers in core `IInspectable` implementation (#3057) --- crates/libs/core/src/inspectable.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/libs/core/src/inspectable.rs b/crates/libs/core/src/inspectable.rs index 3208618b4d..de6b676610 100644 --- a/crates/libs/core/src/inspectable.rs +++ b/crates/libs/core/src/inspectable.rs @@ -65,6 +65,9 @@ impl IInspectable_Vtbl { count: *mut u32, values: *mut *mut GUID, ) -> HRESULT { + if count.is_null() || values.is_null() { + return imp::E_POINTER; + } // Note: even if we end up implementing this in future, it still doesn't need a this pointer // since the data to be returned is type- not instance-specific so can be shared for all // interfaces. @@ -76,6 +79,9 @@ impl IInspectable_Vtbl { _: *mut c_void, value: *mut *mut c_void, ) -> HRESULT { + if value.is_null() { + return imp::E_POINTER; + } let h: HSTRING = T::NAME.into(); // TODO: should be try_into *value = transmute::(h); HRESULT(0) @@ -84,6 +90,9 @@ impl IInspectable_Vtbl { this: *mut c_void, value: *mut i32, ) -> HRESULT { + if value.is_null() { + return imp::E_POINTER; + } let this = (this as *mut *mut c_void).offset(OFFSET) as *mut T; (*this).GetTrustLevel(value) }