From 00890aecdf6a117ecf2a74632ffe9b7eed6e6606 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 13 Aug 2020 18:33:18 +0000 Subject: [PATCH] core(ocl): fix ocl::Image2d::isFormatSupported() in case of OPENCV_OPENCL_DEVICE=disabled --- modules/core/src/ocl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index c6b6e2f0f0..62de280812 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -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,