rusticl/icd: fix ReferenceCountedAPIPointer::from_ptr for NULL pointers
If a NULL pointer is passed in, we have to return one as well. Signed-off-by: Karol Herbst <git@karolherbst.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23573>
This commit is contained in:
@@ -308,6 +308,9 @@ macro_rules! impl_cl_type_trait {
|
||||
}
|
||||
|
||||
fn from_ptr(ptr: *const $t) -> Self {
|
||||
if ptr.is_null() {
|
||||
return std::ptr::null_mut();
|
||||
}
|
||||
let offset = ::mesa_rust_util::offset_of!($t, base);
|
||||
// SAFETY: The resulting pointer is safe as we simply offset into the ICD specified
|
||||
// base type.
|
||||
|
||||
Reference in New Issue
Block a user