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:
Karol Herbst 2023-06-11 12:50:34 +02:00 committed by Marge Bot
parent e358173fbf
commit 30559a399b

View file

@ -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.