avoid use-after-move error

Summary:
* db/range_del_aggregator.cc (AddTombstone): Avoid a potential
use-after-move bug. The original code would both use and move
`tombstone` in a context where the order of those operations is
not specified.  The fix is to perform the use on a new, preceding
statement.

Author: meyering
Closes https://github.com/facebook/rocksdb/pull/2796

Differential Revision: D5721163

Pulled By: ajkr

fbshipit-source-id: a1d328d6a77a17c6425e8069860a202e615e2f48
This commit is contained in:
Andrew Kryczka 2017-08-29 11:57:59 -07:00 committed by Facebook Github Bot
parent c41744270a
commit b767972313

View File

@ -357,7 +357,8 @@ Status RangeDelAggregator::AddTombstone(RangeTombstone tombstone) {
++new_range_dels_iter;
}
} else {
tombstone_map.emplace(tombstone.start_key_, std::move(tombstone));
auto start_key = tombstone.start_key_;
tombstone_map.emplace(start_key, std::move(tombstone));
}
return Status::OK();
}