diff --git a/onnxruntime/core/graph/ep_api_types.cc b/onnxruntime/core/graph/ep_api_types.cc index 1864bfde31d22..1eb7d4f17e581 100644 --- a/onnxruntime/core/graph/ep_api_types.cc +++ b/onnxruntime/core/graph/ep_api_types.cc @@ -543,6 +543,10 @@ void EpGraph::IndexToEpNodeMap::Resize(NodeIndex min_node_index, NodeIndex max_n } EpNode* EpGraph::IndexToEpNodeMap::GetEpNode(NodeIndex node_index) const { + if (node_index < min_node_index_ || node_index >= min_node_index_ + nodes_.size()) { + return nullptr; + } + size_t i = node_index - min_node_index_; assert(i < nodes_.size()); return nodes_[i];