From 04586fc09d5f8cc37b75eb65d7e4d33ad4461005 Mon Sep 17 00:00:00 2001 From: Prabhat Date: Fri, 10 Jul 2020 11:23:12 +0100 Subject: [PATCH] Fix segmentation fault caused by invalid tensor type (#4467) * Fix segmentation fault caused by invalid tensor type * Addressed review comment --- onnxruntime/core/graph/graph.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/onnxruntime/core/graph/graph.cc b/onnxruntime/core/graph/graph.cc index 6ac4d38718..08e001eb8a 100644 --- a/onnxruntime/core/graph/graph.cc +++ b/onnxruntime/core/graph/graph.cc @@ -842,6 +842,10 @@ Graph::Graph(const Model& owning_model, NodeArg* matching_graph_input = GetNodeArg(tensor.name()); TypeProto t{TypeProtoFromTensorProto(tensor)}; + if (!utils::HasElemType(t.tensor_type())) { + ORT_THROW("This is an invalid model. Tensor does not have type information."); + } + if (ir_version_ < 4) { // initializers can have matching graph inputs but are treated as constant, // so we prefer the shape from the initializer