Skip to content

Commit

Permalink
[tf.data / Cloud Bigtable]: Avoid underflow.
Browse files Browse the repository at this point in the history
Previously, because the size_t type is unsigned, if keys_.empty(), we would underflow, instead of returning end_of_sequence, resulting in a runtime crash. This change switches around the arithmetic so that it's robust to underflow.

PiperOrigin-RevId: 219062746
  • Loading branch information
saeta authored and tensorflower-gardener committed Oct 29, 2018
1 parent baf8945 commit e66aea5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class BigtableSampleKeyPairsDatasetOp : public DatasetOpKernel {
std::vector<Tensor>* out_tensors,
bool* end_of_sequence) override {
mutex_lock l(mu_);
if (index_ > keys_.size() - 2) {
if (index_ + 2 > keys_.size()) {
*end_of_sequence = true;
return Status::OK();
}
Expand Down

0 comments on commit e66aea5

Please sign in to comment.