aboutsummaryrefslogtreecommitdiff
path: root/shim/sl/canonical/ArmnnDriverImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shim/sl/canonical/ArmnnDriverImpl.cpp')
-rw-r--r--shim/sl/canonical/ArmnnDriverImpl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/shim/sl/canonical/ArmnnDriverImpl.cpp b/shim/sl/canonical/ArmnnDriverImpl.cpp
index 0f7888bb4b..060dd5a252 100644
--- a/shim/sl/canonical/ArmnnDriverImpl.cpp
+++ b/shim/sl/canonical/ArmnnDriverImpl.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
//
@@ -400,6 +400,11 @@ GeneralResult<SharedPreparedModel> ArmnnDriverImpl::PrepareArmnnModelFromCache(
pread(*dataCacheHandle[0], hashValue.data(), hashValue.size(), 0);
// Read the model
+ if (cachedDataSize < hashValue.size())
+ {
+ return NN_ERROR(ErrorStatus::GENERAL_FAILURE)
+ << "ArmnnDriverImpl::prepareModelFromCache(): cachedDataSize is less than hashValue!";
+ }
std::vector<uint8_t> dataCacheData(cachedDataSize - hashValue.size());
pread(*dataCacheHandle[0], dataCacheData.data(), dataCacheData.size(), hashValue.size());
auto calculatedHashValue = Hash(dataCacheData);