diff --git a/db/memtable.cc b/db/memtable.cc index 4f09340e0..c72fb08e1 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -122,8 +122,10 @@ bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) { const uint64_t tag = DecodeFixed64(key_ptr + key_length - 8); switch (static_cast(tag & 0xff)) { case kTypeValue: { - Slice v = GetLengthPrefixedSlice(key_ptr + key_length); - value->assign(v.data(), v.size()); + if (value) { + Slice v = GetLengthPrefixedSlice(key_ptr + key_length); + value->assign(v.data(), v.size()); + } return true; } case kTypeDeletion: diff --git a/db/version_set.cc b/db/version_set.cc index 6f8b5b5e2..129b9f118 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -267,7 +267,7 @@ static void SaveValue(void* arg, const Slice& ikey, const Slice& v) { } else { if (s->ucmp->Compare(parsed_key.user_key, s->user_key) == 0) { s->state = (parsed_key.type == kTypeValue) ? kFound : kDeleted; - if (s->state == kFound) { + if (s->state == kFound && s->value) { s->value->assign(v.data(), v.size()); } }