From f9155a340412c3ed5a6c1bd71ce44c4b5324df58 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Mon, 20 Apr 2020 16:30:34 -0700 Subject: [PATCH] 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 --- table/block_based/block.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/table/block_based/block.cc b/table/block_based/block.cc index 8afa2cccf..ea1934508 100644 --- a/table/block_based/block.cc +++ b/table/block_based/block.cc @@ -376,14 +376,14 @@ bool DataBlockIter::SeekForGetImpl(const Slice& target) { void IndexBlockIter::Seek(const Slice& target) { TEST_SYNC_POINT("IndexBlockIter::Seek:0"); - Slice seek_key = target; - if (!key_includes_seq_) { - seek_key = ExtractUserKey(target); - } PERF_TIMER_GUARD(block_seek_nanos); if (data_ == nullptr) { // Not init yet return; } + Slice seek_key = target; + if (!key_includes_seq_) { + seek_key = ExtractUserKey(target); + } status_ = Status::OK(); uint32_t index = 0; bool ok = false;