From b18f9c9eace89d63f37432ce1a3dba48bddbcef0 Mon Sep 17 00:00:00 2001 From: Aaron Gao Date: Tue, 30 Aug 2016 13:48:31 -0700 Subject: [PATCH] add nullptr check to internal_prefix_transform Summary: patch for D62361 Test Plan: make all check Reviewers: sdong Reviewed By: sdong Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D62883 --- table/block_based_table_reader.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/table/block_based_table_reader.cc b/table/block_based_table_reader.cc index 49dee3ddd..784110bb3 100644 --- a/table/block_based_table_reader.cc +++ b/table/block_based_table_reader.cc @@ -556,8 +556,10 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions, rep->hash_index_allow_collision = table_options.hash_index_allow_collision; // We need to wrap data with internal_prefix_transform to make sure it can // handle prefix correctly. - rep->internal_prefix_transform.reset( - new InternalKeySliceTransform(rep->ioptions.prefix_extractor)); + if (rep->ioptions.prefix_extractor != nullptr) { + rep->internal_prefix_transform.reset( + new InternalKeySliceTransform(rep->ioptions.prefix_extractor)); + } SetupCacheKeyPrefix(rep, file_size); unique_ptr new_table(new BlockBasedTable(rep)); @@ -1690,6 +1692,7 @@ Status BlockBasedTable::CreateIndexReader( meta_index_iter = meta_iter_guard.get(); } + assert(rep_->internal_prefix_transform); return HashIndexReader::Create( rep_->internal_prefix_transform.get(), footer, file, rep_->ioptions, comparator, footer.index_handle(), meta_index_iter, index_reader,