From 8ba7389b21daa69705949a78320a4854b737e3a2 Mon Sep 17 00:00:00 2001 From: kallaballa Date: Thu, 10 Oct 2024 06:32:22 +0200 Subject: [PATCH] properly size the devices array --- modules/core/src/opengl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index 2de0efcfc6..c249ce715b 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -1642,8 +1642,8 @@ Context& initializeContextFromGL() NO_OPENCL_SHARING_ERROR; #else cl_uint numPlatforms; - cl_device_id* devices = new cl_device_id[256]; cl_uint devCnt; + cl_device_id* devices; cl_uint devUsed; cl_context context; @@ -1667,6 +1667,8 @@ Context& initializeContextFromGL() if (status != CL_SUCCESS) CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: No devices available: %d", status)); + cl_device_id* devices = new cl_device_id[devCnt]; + status = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, devCnt, devices, NULL); if (status != CL_SUCCESS) CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get platform devices: %d", status));