Skip to content

Commit c4b158f

Browse files
committed
Merge pull request opencv#10167 from alalek:ocl_fix_issue_contrib1467
2 parents 92be112 + 92b35e6 commit c4b158f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

modules/core/src/ocl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,7 @@ struct Context::Impl
20292029
{
20302030
if (prefix.empty())
20312031
{
2032+
CV_Assert(!devices.empty());
20322033
const Device& d = devices[0];
20332034
prefix = d.vendorName() + "--" + d.name() + "--" + d.driverVersion();
20342035
// sanitize chars
@@ -3298,6 +3299,8 @@ struct Program::Impl
32983299
refcount = 1;
32993300
const Context ctx = Context::getDefault();
33003301
Device device = ctx.device(0);
3302+
if (ctx.ptr() == NULL || device.ptr() == NULL)
3303+
return;
33013304
if (device.isAMD())
33023305
buildflags += " -D AMD_DEVICE";
33033306
else if (device.isIntel())
@@ -3308,6 +3311,7 @@ struct Program::Impl
33083311
bool compile(const Context& ctx, String& errmsg)
33093312
{
33103313
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
3314+
CV_Assert(ctx.getImpl());
33113315
OpenCLBinaryCacheConfigurator& config = OpenCLBinaryCacheConfigurator::getSingletonInstance();
33123316
const std::string base_dir = config.prepareCacheDirectoryForContext(
33133317
ctx.getImpl()->getPrefixString(),

0 commit comments

Comments
 (0)