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
main
Andrew Kryczka 7 years ago committed by Facebook Github Bot
parent c41744270a
commit b767972313
  1. 3
      db/range_del_aggregator.cc

@ -357,7 +357,8 @@ Status RangeDelAggregator::AddTombstone(RangeTombstone tombstone) {
++new_range_dels_iter; ++new_range_dels_iter;
} }
} else { } 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(); return Status::OK();
} }

Loading…
Cancel
Save