Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix a null pointer exception caused by branching on uninitialized data.
This is due to not checking that the params for the quantization exists. If there is no quantization, we should not access the `.params` field.

PiperOrigin-RevId: 385163909
Change-Id: I2beb8d50649b6542db224c163033fbcbaa49314f
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Jul 16, 2021
1 parent 2c3baf9 commit 537bc7c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tensorflow/lite/kernels/svdf.cc
Expand Up @@ -256,14 +256,21 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
output_temp_size_array));

// Calculate effective scales.
TF_LITE_ENSURE(context, input->quantization.type != kTfLiteNoQuantization);
auto* input_params =
reinterpret_cast<TfLiteAffineQuantization*>(input->quantization.params);
TF_LITE_ENSURE(context,
weights_feature->quantization.type != kTfLiteNoQuantization);
auto* weights_feature_params = reinterpret_cast<TfLiteAffineQuantization*>(
weights_feature->quantization.params);
TF_LITE_ENSURE(context, state->quantization.type != kTfLiteNoQuantization);
auto* state_params =
reinterpret_cast<TfLiteAffineQuantization*>(state->quantization.params);
TF_LITE_ENSURE(context,
weights_time->quantization.type != kTfLiteNoQuantization);
auto* weight_time_params = reinterpret_cast<TfLiteAffineQuantization*>(
weights_time->quantization.params);
TF_LITE_ENSURE(context, output->quantization.type != kTfLiteNoQuantization);
auto* output_params = reinterpret_cast<TfLiteAffineQuantization*>(
output->quantization.params);
const double effective_scale_1 = input_params->scale->data[0] *
Expand Down

0 comments on commit 537bc7c

Please sign in to comment.