From e3c7224142bff60635157e36c2cce91782b4aaeb Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Fri, 24 May 2024 10:44:38 -0500 Subject: [PATCH 1/2] E_POINTER --- 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 bd61b95e1e..44cefe4beb 100644 --- a/crates/libs/core/src/inspectable.rs +++ b/crates/libs/core/src/inspectable.rs @@ -56,6 +56,9 @@ impl RuntimeName for IInspectable {} impl IInspectable_Vtbl { pub const fn new() -> Self { unsafe extern "system" fn GetIids(_: *mut c_void, 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. @@ -64,11 +67,17 @@ impl IInspectable_Vtbl { HRESULT(0) } unsafe extern "system" fn GetRuntimeClassName(_: *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) } unsafe extern "system" fn GetTrustLevel(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) } From 974963ce7d412c0adfcb943808ee42f4f2e1a20d Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Tue, 4 Jun 2024 09:31:28 -0500 Subject: [PATCH 2/2] fmt --- crates/libs/core/src/inspectable.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/libs/core/src/inspectable.rs b/crates/libs/core/src/inspectable.rs index fba5524524..de6b676610 100644 --- a/crates/libs/core/src/inspectable.rs +++ b/crates/libs/core/src/inspectable.rs @@ -60,7 +60,11 @@ impl RuntimeName for IInspectable {} impl IInspectable_Vtbl { pub const fn new() -> Self { - unsafe extern "system" fn GetIids(_: *mut c_void, count: *mut u32, values: *mut *mut GUID) -> HRESULT { + unsafe extern "system" fn GetIids( + _: *mut c_void, + count: *mut u32, + values: *mut *mut GUID, + ) -> HRESULT { if count.is_null() || values.is_null() { return imp::E_POINTER; } @@ -71,7 +75,10 @@ impl IInspectable_Vtbl { *values = null_mut(); HRESULT(0) } - unsafe extern "system" fn GetRuntimeClassName(_: *mut c_void, value: *mut *mut c_void) -> HRESULT { + unsafe extern "system" fn GetRuntimeClassName( + _: *mut c_void, + value: *mut *mut c_void, + ) -> HRESULT { if value.is_null() { return imp::E_POINTER; } @@ -79,7 +86,10 @@ impl IInspectable_Vtbl { *value = transmute::(h); HRESULT(0) } - unsafe extern "system" fn GetTrustLevel(this: *mut c_void, value: *mut i32) -> HRESULT { + unsafe extern "system" fn GetTrustLevel( + this: *mut c_void, + value: *mut i32, + ) -> HRESULT { if value.is_null() { return imp::E_POINTER; }