Skip to content

Commit 5b048e8

Browse files
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
1 parent fd3c67f commit 5b048e8

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

tensorflow/lite/kernels/kernel_util.cc

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ TfLiteStatus GetInputSafe(const TfLiteContext* context, const TfLiteNode* node,
119119
TfLiteTensor* GetVariableInput(TfLiteContext* context, const TfLiteNode* node,
120120
int index) {
121121
TfLiteTensor* tensor = GetMutableInput(context, node, index);
122+
if (tensor == nullptr) return nullptr;
122123
return tensor->is_variable ? tensor : nullptr;
123124
}
124125

tensorflow/lite/kernels/svdf.cc

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
299299
GetTemporarySafe(context, node, /*index=*/0, &scratch));
300300

301301
TfLiteTensor* state = GetVariableInput(context, node, kStateTensor);
302+
TF_LITE_ENSURE(context, state != nullptr);
302303
TfLiteTensor* output;
303304
TF_LITE_ENSURE_OK(context,
304305
GetOutputSafe(context, node, kOutputTensor, &output));

0 commit comments

Comments
 (0)