From 1fe9ecb67baa368118f275fa87021069cb178a28 Mon Sep 17 00:00:00 2001 From: Show Liu Date: Wed, 29 Jul 2015 16:59:46 +0800 Subject: To check the device is NULL or not to avoid the crash issue --- src/core/kernel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/kernel.cpp b/src/core/kernel.cpp index 92a0cca..c3fe391 100644 --- a/src/core/kernel.cpp +++ b/src/core/kernel.cpp @@ -83,6 +83,10 @@ Kernel::~Kernel() static bool matchDeviceOrParent(DeviceInterface *device_dep, DeviceInterface *device) { bool match = (device_dep == device); + + if (device == NULL) + return match; + DeviceInterface *next_device = device->parentDevice(); // If no match, device could be a sub-device - so go up the hierarchy checking parents: @@ -757,6 +761,9 @@ cl_int Kernel::workGroupInfo(DeviceInterface *device, cl_ulong cl_ulong_var; }; + if (device == NULL) + return CL_INVALID_DEVICE; + const DeviceDependent &dep = deviceDependent(device); if ((!device && p_device_dependent.size() > 1) || (&dep == &null_dep)) -- cgit v1.2.3