Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix a null pointer exception in SVDF
This is due to not checking that `GetVariableInput` returns non-null tensor.

Also fix a potential null pointer exception in `GetVariableInput`.

PiperOrigin-RevId: 385160147
Change-Id: Iadf3f0705b036a9014d27caa5a8bbd91f4c4c401
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Jul 16, 2021
1 parent fd3c67f commit 5b048e8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions tensorflow/lite/kernels/kernel_util.cc
Expand Up @@ -119,6 +119,7 @@ TfLiteStatus GetInputSafe(const TfLiteContext* context, const TfLiteNode* node,
TfLiteTensor* GetVariableInput(TfLiteContext* context, const TfLiteNode* node,
int index) {
TfLiteTensor* tensor = GetMutableInput(context, node, index);
if (tensor == nullptr) return nullptr;
return tensor->is_variable ? tensor : nullptr;
}

Expand Down
1 change: 1 addition & 0 deletions tensorflow/lite/kernels/svdf.cc
Expand Up @@ -299,6 +299,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
GetTemporarySafe(context, node, /*index=*/0, &scratch));

TfLiteTensor* state = GetVariableInput(context, node, kStateTensor);
TF_LITE_ENSURE(context, state != nullptr);
TfLiteTensor* output;
TF_LITE_ENSURE_OK(context,
GetOutputSafe(context, node, kOutputTensor, &output));
Expand Down

0 comments on commit 5b048e8

Please sign in to comment.