Skip to content

Commit 1a9da9f

Browse files
authored
Adding null check avoid dereferencing prior to init (#2547) (#2548)
1 parent 4ee11fd commit 1a9da9f

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

include/oneapi/dpl/internal/dynamic_selection_impl/auto_tune_policy.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ class auto_tune_policy : public policy_base<auto_tune_policy<ResourceType, Resou
208208
static_assert(sizeof...(KeyArgs) == sizeof...(Args));
209209
if constexpr (backend_traits<Backend>::lazy_report_v)
210210
{
211-
this->backend_->lazy_report();
211+
if (this->backend_)
212+
this->backend_->lazy_report();
213+
else
214+
throw std::logic_error("selection called before initialization");
212215
}
213216
if (state_)
214217
{

include/oneapi/dpl/internal/dynamic_selection_impl/dynamic_load_policy.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ class dynamic_load_policy
125125
{
126126
if constexpr (backend_traits<Backend>::lazy_report_v)
127127
{
128-
this->backend_->lazy_report();
128+
if (this->backend_)
129+
this->backend_->lazy_report();
130+
else
131+
throw std::logic_error("selection called before initialization");
129132
}
130133
if (selector_)
131134
{

0 commit comments

Comments
 (0)