Prevent uninitialized load in `IndexBlockIter` (#6736)

Summary:
When index block is empty or an error happens while reading it,
`Invalidate()` is called rather than `Initialize()`. So `Seek()` must
not refer to member variables that are only initialized in
`Initialize()` until it is sure `Initialize()` has been called.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6736

Reviewed By: siying

Differential Revision: D21139641

Pulled By: ajkr

fbshipit-source-id: 71c58cc1adbd795dc3729dd5023bf7df1515ff32
main
Andrew Kryczka 5 years ago committed by Facebook GitHub Bot
parent 03a1d95db0
commit f9155a3404
  1. 8
      table/block_based/block.cc

@ -376,14 +376,14 @@ bool DataBlockIter::SeekForGetImpl(const Slice& target) {
void IndexBlockIter::Seek(const Slice& target) { void IndexBlockIter::Seek(const Slice& target) {
TEST_SYNC_POINT("IndexBlockIter::Seek:0"); TEST_SYNC_POINT("IndexBlockIter::Seek:0");
Slice seek_key = target;
if (!key_includes_seq_) {
seek_key = ExtractUserKey(target);
}
PERF_TIMER_GUARD(block_seek_nanos); PERF_TIMER_GUARD(block_seek_nanos);
if (data_ == nullptr) { // Not init yet if (data_ == nullptr) { // Not init yet
return; return;
} }
Slice seek_key = target;
if (!key_includes_seq_) {
seek_key = ExtractUserKey(target);
}
status_ = Status::OK(); status_ = Status::OK();
uint32_t index = 0; uint32_t index = 0;
bool ok = false; bool ok = false;

Loading…
Cancel
Save