From: chunseoklee Date: Tue, 8 Sep 2020 11:05:02 +0000 (+0900) Subject: Fix coverity1148326 (#4131) X-Git-Tag: accepted/tizen/unified/20200909.155544~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d2787ea4bdc332168c313a3e56b424454d7acbd;p=platform%2Fcore%2Fml%2Fnnfw.git Fix coverity1148326 (#4131) Fix coverity defect : Integer overflowed argument ``` 6. overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or truncated value) num_of_interm_tensors - 1U used as critical argument to function. [show details] _interm_tensors[num_of_interm_tensors - 1].allocator()->allocate(); ``` ONE-DCO-1.0-Signed-off-by: Chunseok Lee --- diff --git a/compute/ARMComputeEx/src/runtime/CL/functions/CLReduceOperation.cpp b/compute/ARMComputeEx/src/runtime/CL/functions/CLReduceOperation.cpp index 3840110..321d5c5 100644 --- a/compute/ARMComputeEx/src/runtime/CL/functions/CLReduceOperation.cpp +++ b/compute/ARMComputeEx/src/runtime/CL/functions/CLReduceOperation.cpp @@ -120,6 +120,8 @@ void CLReduceOperation::configure(ICLTensor *input, ICLTensor *output, const size_t num_of_kernels = axis.size(); const size_t num_of_interm_tensors = num_of_kernels - (keep_dims ? 1 : 0); + ARM_COMPUTE_ERROR_ON(num_of_kernels < 1); + _interm_tensors = support::cpp14::make_unique(num_of_interm_tensors); _reduce_kernels = support::cpp14::make_unique(num_of_kernels);