From a1b5bfc4f82beaa616b1f5d8b035494b5ccc02cf Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Wed, 20 Jan 2021 22:05:42 +0530 Subject: [PATCH] Fix SDL warning (#6390) --- onnxruntime/test/optimizer/cse_test.cc | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/onnxruntime/test/optimizer/cse_test.cc b/onnxruntime/test/optimizer/cse_test.cc index 3ad91954cc..cbae298289 100644 --- a/onnxruntime/test/optimizer/cse_test.cc +++ b/onnxruntime/test/optimizer/cse_test.cc @@ -222,22 +222,29 @@ TEST(CseTests, Subgraph) { } } + // Assert that we were able to obtain subgraphs pertaining to the then/else attributes in the 'If' node ASSERT_NE(if_true_graph, nullptr); ASSERT_NE(if_false_graph, nullptr); - output_names = GetSortedNames(if_true_graph->GetOutputs()); - ASSERT_EQ(output_names, (std::vector{"Result1", "Result2", "Result3"})); + // Keep VC++ static analyzer happy + if (if_true_graph) { + output_names = GetSortedNames(if_true_graph->GetOutputs()); + ASSERT_EQ(output_names, (std::vector{"Result1", "Result2", "Result3"})); - auto op_count = CountOpsInGraph(*if_true_graph); - ASSERT_EQ(op_count["Mul"], 1); - ASSERT_EQ(op_count["Sum"], 3); + auto op_count = CountOpsInGraph(*if_true_graph); + ASSERT_EQ(op_count["Mul"], 1); + ASSERT_EQ(op_count["Sum"], 3); + } - output_names = GetSortedNames(if_false_graph->GetOutputs()); - ASSERT_EQ(output_names, (std::vector{"Result1", "Result2", "Result3"})); + // Keep VC++ static analyzer happy + if (if_false_graph) { + output_names = GetSortedNames(if_false_graph->GetOutputs()); + ASSERT_EQ(output_names, (std::vector{"Result1", "Result2", "Result3"})); - op_count = CountOpsInGraph(*if_false_graph); - ASSERT_EQ(op_count["Mul"], 3); - ASSERT_EQ(op_count["Sum"], 1); + auto op_count = CountOpsInGraph(*if_false_graph); + ASSERT_EQ(op_count["Mul"], 3); + ASSERT_EQ(op_count["Sum"], 1); + } } TEST(CseTests, MergedValueAndGraphOutputAreOutputsOfSameNode) {