mirror of
https://github.com/google/leveldb.git
synced 2025-01-27 06:30:07 +08:00
fix undefined behavior due to reading iterator data after modification
This commit is contained in:
parent
aa5479bbf4
commit
6794944c00
@ -30,14 +30,15 @@ Status BuildTable(const std::string& dbname, Env* env, const Options& options,
|
||||
|
||||
TableBuilder* builder = new TableBuilder(options, file);
|
||||
meta->smallest.DecodeFrom(iter->key());
|
||||
Slice key;
|
||||
for (; iter->Valid(); iter->Next()) {
|
||||
key = iter->key();
|
||||
builder->Add(key, iter->value());
|
||||
builder->Add(iter->key(), iter->value());
|
||||
}
|
||||
if (!key.empty()) {
|
||||
meta->largest.DecodeFrom(key);
|
||||
|
||||
iter->SeekToLast();
|
||||
if(iter->Valid()) {
|
||||
meta->largest.DecodeFrom(iter->key());
|
||||
}
|
||||
|
||||
|
||||
// Finish and check for builder errors
|
||||
s = builder->Finish();
|
||||
|
Loading…
Reference in New Issue
Block a user