aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColm Donelan <colm.donelan@arm.com>2023-01-24 22:10:12 +0000
committerColm Donelan <colm.donelan@arm.com>2023-01-25 11:28:42 +0000
commit18e6f04232b8aecaec9a232057ac3cb16e4f56f5 (patch)
tree87144020143756a5ff496eccca6f79075b5e29bb
parent04d8229bb3e78d1b1dd21eed41e47aabc25d8e2f (diff)
downloadarmnn-18e6f04232b8aecaec9a232057ac3cb16e4f56f5.tar.gz
IVGCVSW-7441 Fixing null pointers in ExecuteNetwork.
* Check if BuildExecutor returns null in ExecuteNetwork. * Check if tflite BuildFromFile returns null in TfliteExecutor. Signed-off-by: Colm Donelan <colm.donelan@arm.com> Change-Id: I42b6e5f26dfd127dd16b6b322184900846317c41
-rw-r--r--tests/ExecuteNetwork/ExecuteNetwork.cpp6
-rw-r--r--tests/ExecuteNetwork/TfliteExecutor.cpp5
2 files changed, 7 insertions, 4 deletions
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index c6c8cc0b27..a70f33ff23 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -20,7 +20,7 @@ std::unique_ptr<IExecutor> BuildExecutor(ProgramOptions& programOptions)
return std::make_unique<TfLiteExecutor>(programOptions.m_ExNetParams);
#else
ARMNN_LOG(fatal) << "Not built with Arm NN Tensorflow-Lite delegate support.";
- return nullptr;
+ return nullptr;
#endif
}
else
@@ -59,7 +59,7 @@ int main(int argc, const char* argv[])
try
{
executor = BuildExecutor(programOptions);
- if (executor->m_constructionFailed)
+ if ((!executor) || (executor->m_constructionFailed))
{
return EXIT_FAILURE;
}
diff --git a/tests/ExecuteNetwork/TfliteExecutor.cpp b/tests/ExecuteNetwork/TfliteExecutor.cpp
index 6a799548bf..810495fe8c 100644
--- a/tests/ExecuteNetwork/TfliteExecutor.cpp
+++ b/tests/ExecuteNetwork/TfliteExecutor.cpp
@@ -8,7 +8,10 @@
TfLiteExecutor::TfLiteExecutor(const ExecuteNetworkParams& params) : m_Params(params)
{
m_Model = tflite::FlatBufferModel::BuildFromFile(m_Params.m_ModelPath.c_str());
-
+ if (!m_Model)
+ {
+ LogAndThrow("Failed to load TfLite model from: " + m_Params.m_ModelPath);
+ }
m_TfLiteInterpreter = std::make_unique<Interpreter>();
tflite::ops::builtin::BuiltinOpResolver resolver;