Skip to content

Commit 1b2b9dd

Browse files
authored
[SYCL] Check HostPtr is not null in SYCLMemObjT (#10426)
Signed-off-by: Michael Aziz <[email protected]>
1 parent 557204a commit 1b2b9dd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sycl/source/detail/sycl_mem_obj_t.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,15 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
186186
});
187187
}
188188

189-
if (canReuseHostPtr(HostPtr, RequiredAlign)) {
190-
MUserPtr = HostPtr;
191-
} else {
192-
setAlign(RequiredAlign);
193-
MShadowCopy = allocateHostMem();
194-
MUserPtr = MShadowCopy;
195-
std::memcpy(MUserPtr, HostPtr, MSizeInBytes);
189+
if (HostPtr) {
190+
if (canReuseHostPtr(HostPtr, RequiredAlign)) {
191+
MUserPtr = HostPtr;
192+
} else {
193+
setAlign(RequiredAlign);
194+
MShadowCopy = allocateHostMem();
195+
MUserPtr = MShadowCopy;
196+
std::memcpy(MUserPtr, HostPtr, MSizeInBytes);
197+
}
196198
}
197199
}
198200

0 commit comments

Comments
 (0)