Skip to content

Commit 5c8a86b

Browse files
committed
[OpenCL] Fix some unchecked dereferencing of optional params.
1 parent f0de2f4 commit 5c8a86b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

source/adapters/opencl/kernel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel, ur_device_handle_t hDevice,
199199
}
200200
}
201201

202-
*(static_cast<uint32_t *>(pPropValue)) = static_cast<uint32_t>(RetVal);
202+
if (pPropValue)
203+
*(static_cast<uint32_t *>(pPropValue)) = static_cast<uint32_t>(RetVal);
203204
if (pPropSizeRet)
204205
*pPropSizeRet = sizeof(uint32_t);
205206

source/adapters/opencl/memory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate(
268268
}
269269
}
270270

271+
void *HostPtr = pProperties ? pProperties->pHost : nullptr;
271272
*phBuffer = reinterpret_cast<ur_mem_handle_t>(clCreateBuffer(
272273
cl_adapter::cast<cl_context>(hContext), static_cast<cl_mem_flags>(flags),
273-
size, pProperties->pHost, cl_adapter::cast<cl_int *>(&RetErr)));
274+
size, HostPtr, cl_adapter::cast<cl_int *>(&RetErr)));
274275
CL_RETURN_ON_FAILURE(RetErr);
275276

276277
return UR_RESULT_SUCCESS;

0 commit comments

Comments
 (0)