diff --git a/rai/plat/posix/openclapi.cpp b/rai/plat/posix/openclapi.cpp index 4b3240a0..915a6b9c 100644 --- a/rai/plat/posix/openclapi.cpp +++ b/rai/plat/posix/openclapi.cpp @@ -21,7 +21,7 @@ public: clCreateBuffer = reinterpret_cast (dlsym(opencl_library, "clCreateBuffer")); clCreateProgramWithSource = reinterpret_cast (dlsym(opencl_library, "clCreateProgramWithSource")); clBuildProgram = reinterpret_cast (dlsym(opencl_library, "clBuildProgram")); - clGetProgramBuildInfo = reinterpret_cast (GetProcAddress(opencl_library, "clGetProgramBuildInfo")); + clGetProgramBuildInfo = reinterpret_cast (dlsym(opencl_library, "clGetProgramBuildInfo")); clCreateKernel = reinterpret_cast (dlsym(opencl_library, "clCreateKernel")); clSetKernelArg = reinterpret_cast (dlsym(opencl_library, "clSetKernelArg")); clReleaseKernel = reinterpret_cast (dlsym(opencl_library, "clReleaseKernel")); @@ -35,7 +35,10 @@ public: } ~opencl_initializer () { - dlclose (opencl_library); + if (opencl_library != nullptr) + { + dlclose (opencl_library); + } } void * opencl_library; cl_int (* clGetPlatformIDs) (cl_uint, cl_platform_id *, cl_uint *); @@ -73,7 +76,10 @@ cl_int clGetPlatformIDs (cl_uint num_entries, cl_platform_id * platforms, cl_uin else { result = CL_SUCCESS; - *num_platforms = 0; + if (num_platforms != nullptr) + { + *num_platforms = 0; + } } return result; } diff --git a/rai/plat/windows/openclapi.cpp b/rai/plat/windows/openclapi.cpp index 46883c89..ba2ac6d9 100644 --- a/rai/plat/windows/openclapi.cpp +++ b/rai/plat/windows/openclapi.cpp @@ -35,7 +35,10 @@ namespace } ~opencl_initializer() { - FreeLibrary(opencl_library); + if (opencl_library != nullptr) + { + FreeLibrary(opencl_library); + } } HMODULE opencl_library; cl_int(*clGetPlatformIDs) (cl_uint, cl_platform_id *, cl_uint *);