From 8c52c596d298ddaaa6e60bdbd17766e83dfe3edd Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 22 Feb 2021 19:51:02 +0000 Subject: Check cpu index is within a valid range when populating cpu information Signed-off-by: Georgios Pinitas Change-Id: I994fd72ed33d42b75d6ae6ef1fc5972faa3b4bf8 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5149 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/runtime/CPUUtils.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/CPUUtils.cpp b/src/runtime/CPUUtils.cpp index 74f0f58248..6f51ee62ed 100644 --- a/src/runtime/CPUUtils.cpp +++ b/src/runtime/CPUUtils.cpp @@ -25,6 +25,7 @@ #include "arm_compute/core/CPP/CPPTypes.h" #include "arm_compute/core/Error.h" +#include "arm_compute/core/Log.h" #include "support/StringSupport.h" #include @@ -290,10 +291,14 @@ void populate_models_cpuinfo(std::vector &cpusv) } } - if(curcpu >= 0) + if(curcpu >= 0 && curcpu < static_cast(cpusv.size())) { cpusv[curcpu] = midr_to_model(midr); } + else + { + ARM_COMPUTE_LOG_INFO_MSG_CORE("Trying to populate a core id with id greater than the expected number of cores!"); + } } // Free allocated memory -- cgit v1.2.1