From 84d63785eb2dceba297a685ebd98f1d29be47326 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Fri, 6 May 2022 12:14:16 +0100 Subject: IVGCVSW-6929 Fix for segfault in tflite delegate * It's possible that a model may have an input entry for bias tensors but that the index for those is -1. If it's -1 then it's not present. * Fixed logic error in IsOptionalOperandPresent: it returned false if it was present and true if it was missing. Signed-off-by: Mike Kelly Change-Id: I45ad8d8552122493c529b1a35a5689416ccfbb71 --- delegate/src/DelegateUtils.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'delegate/src/DelegateUtils.hpp') diff --git a/delegate/src/DelegateUtils.hpp b/delegate/src/DelegateUtils.hpp index e0ba1cf4e7..46b2db9d64 100644 --- a/delegate/src/DelegateUtils.hpp +++ b/delegate/src/DelegateUtils.hpp @@ -586,11 +586,13 @@ TfLiteStatus ConnectConstant(armnn::IConnectableLayer* layer, bool IsOptionalOperandPresent(TfLiteNode* tfLiteNode, const int operandIndex) { - if (tfLiteNode->inputs->data[operandIndex] < 0) { + // If the inputs array has fewer than operandIndex entries or if the entry at operandIndex has a value of -1 or + // less then the input is not present. + if (tfLiteNode->inputs->size > operandIndex && tfLiteNode->inputs->data[operandIndex] >= 0) + { return true; } return false; - } TfLiteStatus ProcessInputs(armnn::IConnectableLayer* layer, -- cgit v1.2.1