From 0282b884ccb2bbcfbb895517829a5a23fbc8a54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 26 Jan 2024 09:02:23 +0800 Subject: [PATCH] OpenCL: fix possible segfaults Found in Alpine Linux --- src/detection/opencl/opencl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index 3402c9311..957c1c1dc 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -23,15 +23,15 @@ typedef struct OpenCLData static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { - cl_platform_id platformID; - cl_uint numPlatforms; + cl_platform_id platformID = NULL; + cl_uint numPlatforms = 0; data->ffclGetPlatformIDs(1, &platformID, &numPlatforms); if(numPlatforms == 0) return "clGetPlatformIDs returned 0 platforms"; - cl_device_id deviceID; - cl_uint numDevices; + cl_device_id deviceID = NULL; + cl_uint numDevices = 0; data->ffclGetDeviceIDs(platformID, CL_DEVICE_TYPE_GPU, 1, &deviceID, &numDevices); if(numDevices == 0) @@ -40,7 +40,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) if(numDevices == 0) return "clGetDeviceIDs returned 0 devices"; - char version[64]; + char version[64] = ""; data->ffclGetDeviceInfo(deviceID, CL_DEVICE_VERSION, sizeof(version), version, NULL); if(!ffStrSet(version)) return "clGetDeviceInfo returned NULL or empty string";