Fix use after free in nonwrapping_range::intersection

end_bound() returns temporary object (end_bound_ref), so it cannot be
taken by reference here and used later. Copy instead.

Message-Id: <20170612132328.GJ21915@scylladb.com>
This commit is contained in:
Gleb Natapov
2017-06-12 16:23:28 +03:00
committed by Duarte Nunes
parent 20095d7ed6
commit 21197981a5

View File

@@ -664,7 +664,7 @@ public:
return wrapping_range<T>::less_than(a.start_bound(), b.start_bound(), cmp);
});
if (wrapping_range<T>::greater_than_or_equal(p.first.end_bound(), p.second.start_bound(), cmp)) {
auto& end = std::min(p.first.end_bound(), p.second.end_bound(), [&cmp] (auto&& a, auto&& b) {
auto end = std::min(p.first.end_bound(), p.second.end_bound(), [&cmp] (auto&& a, auto&& b) {
return !wrapping_range<T>::greater_than_or_equal(a, b, cmp);
});
return nonwrapping_range(p.second.start(), end.b);