Skip to content

Commit cfe7c77

Browse files
mingyueliuhJaswanth51
authored andcommitted
[Fix] illegal memory access in GetInputIndices with optional inputs (microsoft#25881)
### Description Fix illegal memory access in GetInputIndices with optional inputs ### Motivation and Context When an input is optional, its ValueInfo may be nullptr. The current implementation directly calls InputValueInfo->GetName(), leading to illegal memory access. Update logic to skip optional inputs when valueInfo is nullptr .
1 parent 248eaf0 commit cfe7c77

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

onnxruntime/core/graph/ep_api_types.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ static Status GetInputIndices(const EpNode& consumer_node,
327327
[&found, &value_info_name, &indices](gsl::span<const EpValueInfo* const> input_value_infos,
328328
bool is_implicit) -> void {
329329
for (size_t i = 0; i < input_value_infos.size(); i++) {
330+
if (input_value_infos[i] == nullptr) { // input_value_info == nullptr means the input is optional
331+
continue;
332+
}
330333
if (input_value_infos[i]->GetName() == value_info_name) {
331334
indices.push_back(is_implicit ? -1 : static_cast<int64_t>(i));
332335
found = true;

0 commit comments

Comments
 (0)