core(ocl): fix ocl::Image2d::isFormatSupported()
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Thu, 13 Aug 2020 18:33:18 +0000 (18:33 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Thu, 13 Aug 2020 18:33:18 +0000 (18:33 +0000)
in case of OPENCV_OPENCL_DEVICE=disabled

modules/core/src/ocl.cpp

index c6b6e2f0f0e88eb147690f6d5ba91e7852ec713f..62de280812d99bedfc37f765a98e87dcb62932e8 100644 (file)
@@ -6458,6 +6458,9 @@ struct Image2D::Impl
             CV_Error(Error::OpenCLApiCallError, "OpenCL runtime not found!");
 
         cl_context context = (cl_context)Context::getDefault().ptr();
+        if (!context)
+            return false;
+
         // Figure out how many formats are supported by this context.
         cl_uint numFormats = 0;
         cl_int err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE,