From 30559a399b90762b61fa406b225b7dde45ba076a Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sun, 11 Jun 2023 12:50:34 +0200 Subject: [PATCH] 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 Part-of: --- src/gallium/frontends/rusticl/api/icd.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/frontends/rusticl/api/icd.rs b/src/gallium/frontends/rusticl/api/icd.rs index b83b17689a7..1393de54c4f 100644 --- a/src/gallium/frontends/rusticl/api/icd.rs +++ b/src/gallium/frontends/rusticl/api/icd.rs @@ -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.