Merge pull request #568 from stweil/opencl

opencl: Fix runtime crash when no device was found
This commit is contained in:
zdenop 2016-12-15 22:00:25 +01:00 committed by GitHub
commit cb886a04ad

View File

@ -120,14 +120,14 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, nullptr, &num);
numDevices+=num;
}
if (numDevices == 0)
goto cleanup;
if (numDevices > 0) {
devices = (cl_device_id*)malloc(numDevices*sizeof(cl_device_id));
if (devices == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
}
}
profile->numDevices = numDevices+1; // +1 to numDevices to include the native CPU
profile->devices =