diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index c36c9618..95844696 100644 --- a/scripts/templates/libapi.cpp.mako +++ b/scripts/templates/libapi.cpp.mako @@ -166,7 +166,7 @@ ${th.make_func_name(n, tags, obj)}( return ${X}_RESULT_ERROR_UNINITIALIZED; } %if re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj)): - if (${x}_lib::context->${n}DdiTable == nullptr) { + if (!${x}_lib::context || ${x}_lib::context->${n}DdiTable == nullptr) { return ${X}_RESULT_ERROR_UNINITIALIZED; } %endif diff --git a/source/lib/zes_libapi.cpp b/source/lib/zes_libapi.cpp index 5c0cb2e5..435dca99 100644 --- a/source/lib/zes_libapi.cpp +++ b/source/lib/zes_libapi.cpp @@ -115,7 +115,7 @@ zesDriverGet( if(ze_lib::destruction) { return ZE_RESULT_ERROR_UNINITIALIZED; } - if (ze_lib::context->zesDdiTable == nullptr) { + if (!ze_lib::context || ze_lib::context->zesDdiTable == nullptr) { return ZE_RESULT_ERROR_UNINITIALIZED; } static const zes_pfnDriverGet_t pfnGet = [&result] {