From 0326eae38bfe3788338664f2d99924e24a19895f Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 27 Jun 2017 15:46:05 +0100 Subject: COMPMID-417: Check for nullptr in mismatching data types check. Change-Id: Iff395b0d5f2858b3e24aad74c7cfd0a1fa6bb6d3 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78999 Reviewed-by: Moritz Pflanzer Tested-by: Kaizen --- arm_compute/core/Validate.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'arm_compute/core/Validate.h') diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h index 48eba70adf..dd71f2c714 100644 --- a/arm_compute/core/Validate.h +++ b/arm_compute/core/Validate.h @@ -249,29 +249,30 @@ void error_on_mismatching_shapes(const char *function, const char *file, const i * @param[in] function Function in which the error occurred. * @param[in] file Name of the file where the error occurred. * @param[in] line Line on which the error occurred. - * @param[in] tensor_1 The first tensor to be compared. - * @param[in] tensor_2 The second tensor to be compared. + * @param[in] tensor The first tensor to be compared. * @param[in] tensors (Optional) Further allowed tensors. */ template void error_on_mismatching_data_types(const char *function, const char *file, const int line, - const ITensor *tensor_1, const ITensor *tensor_2, Ts... tensors) + const ITensor *tensor, Ts... tensors) { ARM_COMPUTE_UNUSED(function); ARM_COMPUTE_UNUSED(file); ARM_COMPUTE_UNUSED(line); - ARM_COMPUTE_UNUSED(tensor_1); - ARM_COMPUTE_UNUSED(tensor_2); + ARM_COMPUTE_UNUSED(tensor); - DataType &&first_data_type = tensor_1->info()->data_type(); - ARM_COMPUTE_UNUSED(first_data_type); + ARM_COMPUTE_ERROR_ON_LOC(tensor == nullptr, function, file, line); + + DataType &&tensor_data_type = tensor->info()->data_type(); + ARM_COMPUTE_UNUSED(tensor_data_type); const std::array tensors_array{ { std::forward(tensors)... } }; ARM_COMPUTE_UNUSED(tensors_array); - ARM_COMPUTE_ERROR_ON_LOC_MSG(tensor_2->info()->data_type() != first_data_type || std::any_of(tensors_array.begin(), tensors_array.end(), [&](const ITensor * tensor) + ARM_COMPUTE_ERROR_ON_LOC_MSG(std::any_of(tensors_array.begin(), tensors_array.end(), [&](const ITensor * tensor_obj) { - return tensor->info()->data_type() != first_data_type; + ARM_COMPUTE_ERROR_ON_LOC(tensor_obj == nullptr, function, file, line); + return tensor_obj->info()->data_type() != tensor_data_type; }), function, file, line, "Tensors have different data types"); } -- cgit v1.2.1