Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for null pointers in core IInspectable implementation #3057

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/libs/core/src/inspectable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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::<HSTRING, *mut c_void>(h);
HRESULT(0)
Expand All @@ -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)
}
Expand Down