diff --git a/onnxruntime/core/graph/graph.cc b/onnxruntime/core/graph/graph.cc index dd3eb59b7fafb..779ca5d180518 100644 --- a/onnxruntime/core/graph/graph.cc +++ b/onnxruntime/core/graph/graph.cc @@ -6483,7 +6483,9 @@ common::Status Graph::LoadFromOrtFormat(const onnxruntime::fbs::Graph& fbs_graph ORT_RETURN_IF(nullptr == fbs_value_info, "NodeArg is missing. Invalid ORT format model."); NodeArgInfo node_arg_info; ORT_RETURN_IF_ERROR(fbs::utils::LoadValueInfoOrtFormat(*fbs_value_info, node_arg_info)); - node_args_[fbs_value_info->name()->str()] = std::make_unique(std::move(node_arg_info)); + const auto* name = fbs_value_info->name(); + ORT_RETURN_IF(name == nullptr, "NodeArg name is missing. Invalid ORT format model."); + node_args_[name->str()] = std::make_unique(std::move(node_arg_info)); } } diff --git a/onnxruntime/test/framework/ort_model_only_test.cc b/onnxruntime/test/framework/ort_model_only_test.cc index 3032b3170a6e0..84e85c7bba7ee 100644 --- a/onnxruntime/test/framework/ort_model_only_test.cc +++ b/onnxruntime/test/framework/ort_model_only_test.cc @@ -592,6 +592,16 @@ TEST(OrtModelOnlyTests, GithubIssue17000) { RunOrtModel(test_info); } +// ICM 31000000518041. +TEST(OrtModelOnlyTests, NullNodeArgNameCheck) { + auto ort_file = ORT_TSTR("testdata/icm-31000000518041.ort"); + + SessionOptions so; + InferenceSessionWrapper session_object{so, GetEnvironment()}; + ASSERT_STATUS_NOT_OK_AND_HAS_SUBSTR(session_object.Load(ort_file), + "NodeArg name is missing. Invalid ORT format model."); +} + #if !defined(DISABLE_ML_OPS) // test that we can deserialize and run a previously saved ORT format model // for a model with sequence and map outputs diff --git a/onnxruntime/test/testdata/icm-31000000518041.ort b/onnxruntime/test/testdata/icm-31000000518041.ort new file mode 100644 index 0000000000000..5fef5256d5602 Binary files /dev/null and b/onnxruntime/test/testdata/icm-31000000518041.ort differ