From 5eafbb50f9ad2b41885fb61a6278708b7264ed2a Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:48:51 -0800 Subject: [PATCH] Fix possible null pointer dereference. (#10373) NodeInfo::p_node was used directly but it can be null from here: https://github.com/microsoft/onnxruntime/blob/2afce4830c9ff48374ca11cf00b09afcc1ff2124/onnxruntime/core/framework/session_state_utils.cc#L381-L382 Add an additional check that it is not null before use. --- onnxruntime/core/session/IOBinding.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/core/session/IOBinding.cc b/onnxruntime/core/session/IOBinding.cc index e0dd66d188..cf49da6860 100644 --- a/onnxruntime/core/session/IOBinding.cc +++ b/onnxruntime/core/session/IOBinding.cc @@ -52,7 +52,7 @@ static common::Status SyncProviders(const SessionState::NameNodeInfoMapType& nod std::set providers; for (auto& pair : node_info_map) { for (auto& node_info : pair.second) { - if (node_info.p_node->GetExecutionProviderType() != onnxruntime::kCpuExecutionProvider) { + if (node_info.p_node && node_info.p_node->GetExecutionProviderType() != onnxruntime::kCpuExecutionProvider) { providers.insert(node_info.p_node->GetExecutionProviderType()); } }