From c0ea933083c5c3c3544c397cda6ec603e0613d38 Mon Sep 17 00:00:00 2001 From: mingyue Date: Wed, 27 Aug 2025 23:52:17 -0500 Subject: [PATCH] [Fix] illegal memory access in GetInputIndices with optional inputs --- onnxruntime/core/graph/ep_api_types.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/onnxruntime/core/graph/ep_api_types.cc b/onnxruntime/core/graph/ep_api_types.cc index 759a2998ace3a..2f945fa987dde 100644 --- a/onnxruntime/core/graph/ep_api_types.cc +++ b/onnxruntime/core/graph/ep_api_types.cc @@ -353,6 +353,9 @@ static Status GetInputIndices(const EpNode& consumer_node, [&found, &value_info_name, &indices](gsl::span input_value_infos, bool is_implicit) -> void { for (size_t i = 0; i < input_value_infos.size(); i++) { + if (input_value_infos[i] == nullptr) { // input_value_info == nullptr means the input is optional + continue; + } if (input_value_infos[i]->GetName() == value_info_name) { indices.push_back(is_implicit ? -1 : static_cast(i)); found = true;