38 lines
1.4 KiB
Diff
38 lines
1.4 KiB
Diff
From 5b048e87e4e55990dae6b547add4dae59f4e1c76 Mon Sep 17 00:00:00 2001
|
|
From: Mihai Maruseac <mihaimaruseac@google.com>
|
|
Date: Fri, 16 Jul 2021 09:14:31 -0700
|
|
ubject: [PATCH] Fix a null pointer exception in SVDF
|
|
|
|
---
|
|
tensorflow/lite/kernels/kernel_util.cc | 1 +
|
|
tensorflow/lite/kernels/svdf.cc | 1 +
|
|
2 files changed, 2 insertions(+)
|
|
|
|
diff --git a/tensorflow/lite/kernels/kernel_util.cc b/tensorflow/lite/kernels/kernel_util.cc
|
|
index f7d7c25b..f0074c09 100644
|
|
--- a/tensorflow/lite/kernels/kernel_util.cc
|
|
+++ b/tensorflow/lite/kernels/kernel_util.cc
|
|
@@ -35,6 +35,7 @@ const TfLiteTensor* GetInput(const TfLiteContext* context,
|
|
TfLiteTensor* GetVariableInput(TfLiteContext* context, const TfLiteNode* node,
|
|
int index) {
|
|
TfLiteTensor* tensor = &context->tensors[node->inputs->data[index]];
|
|
+ if (tensor == nullptr) return nullptr;
|
|
return (tensor->is_variable) ? tensor : nullptr;
|
|
}
|
|
|
|
diff --git a/tensorflow/lite/kernels/svdf.cc b/tensorflow/lite/kernels/svdf.cc
|
|
index ec19fb92..863c18fd 100644
|
|
--- a/tensorflow/lite/kernels/svdf.cc
|
|
+++ b/tensorflow/lite/kernels/svdf.cc
|
|
@@ -281,6 +281,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
|
|
TfLiteTensor* scratch = GetTemporary(context, node, /*index=*/0);
|
|
|
|
TfLiteTensor* state = GetVariableInput(context, node, kStateTensor);
|
|
+ TF_LITE_ENSURE(context, state != nullptr);
|
|
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
|
|
|
|
switch (weights_feature->type) {
|
|
--
|
|
2.23.0
|
|
|