提交 72b86e09 编写于 作者: Z zdenop 提交者: GitHub

Merge pull request #847 from stweil/crash

opencl: Fix crash on hosts with no OpenCL platform
......@@ -170,15 +170,15 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
memset(profile, 0, sizeof(ds_profile));
clGetPlatformIDs(0, nullptr, &numPlatforms);
if (numPlatforms == 0)
goto cleanup;
platforms = (cl_platform_id*)malloc(numPlatforms*sizeof(cl_platform_id));
if (platforms == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
if (numPlatforms > 0) {
platforms = (cl_platform_id*)malloc(numPlatforms*sizeof(cl_platform_id));
if (platforms == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
}
clGetPlatformIDs(numPlatforms, platforms, nullptr);
}
clGetPlatformIDs(numPlatforms, platforms, nullptr);
numDevices = 0;
for (i = 0; i < (unsigned int)numPlatforms; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册