Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix NPE in restoring code.
PiperOrigin-RevId: 388303253
Change-Id: Ia8c68568cb854bca538909a182b31a618d68ce55
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Aug 2, 2021
1 parent e86605c commit 9e82dce
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tensorflow/core/kernels/save_restore_tensor.cc
Expand Up @@ -151,11 +151,18 @@ void RestoreTensor(OpKernelContext* context,
context, size == 1,
errors::InvalidArgument(
"Input 0 (file_pattern) must be a string scalar; got a tensor of ",
size, "elements"));
size, " elements"));
}
const string& file_pattern = file_pattern_t.flat<tstring>()(0);

const Tensor& tensor_name_t = context->input(1);
{
const int64_t size = tensor_name_t.NumElements();
OP_REQUIRES(context, size > restore_index,
errors::InvalidArgument(
"Input 1 (file_pattern) must be a have at least ",
restore_index + 1, " elements"));
}
const string& tensor_name = tensor_name_t.flat<tstring>()(restore_index);

// If we cannot find a cached reader we will allocate our own.
Expand Down

0 comments on commit 9e82dce

Please sign in to comment.