Skip to content

Commit cf751ff

Browse files
committed
fix: Add index validation for batch_index in NECropKernel
Resolves:[COMPMID-8702] Signed-off-by: Omar Al Khatib <omar.alkhatib@arm.com> Change-Id: I04ed0560ebbb2424dd753fc2be1e0cac6da907bd
1 parent 8461ea1 commit cf751ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/NEON/kernels/NECropKernel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2022 Arm Limited.
2+
* Copyright (c) 2019-2022, 2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -323,7 +323,10 @@ void NECropKernel::run(const Window &window, const ThreadInfo &info)
323323

324324
const auto *uk = get_implementation(CropSelectorData{_input->info()->data_type()});
325325

326-
uint32_t batch_index = *(reinterpret_cast<int32_t *>(_box_ind->ptr_to_element(Coordinates(_crop_box_ind))));
326+
uint32_t batch_index = *(reinterpret_cast<int32_t *>(_box_ind->ptr_to_element(Coordinates(_crop_box_ind))));
327+
ARM_COMPUTE_ERROR_ON(batch_index >=
328+
_input->info()->tensor_shape()[3]); // Check if batch_index is outside the number of batches
329+
327330
Coordinates input_offset(
328331
0, _end[0] < _start[0] ? _start[0] - _cols_out_of_bounds[0] : _start[0] + _cols_out_of_bounds[0],
329332
_end[1] < _start[1] ? _start[1] - _rows_out_of_bounds[0] : _start[1] + _rows_out_of_bounds[0], batch_index);

0 commit comments

Comments
 (0)