mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 16:40:35 +00:00
If the range expression in a range based for loop returns a temporary, its lifetime is extended until the end of the loop. The same can't be said about temporaries created within the range expression. In our case, *t->get_sstables_including_compacted_undeleted() returns a reference to a const sstable_list, but the t->get_sstables_including_compacted_undeleted() is a temporary lw_shared_ptr, so its lifetime may not be prolonged until the end of the loop, and it may be the sole owner of the referenced sstable_list, so the referenced sstable_list may be already deleted inside the loop too. Fix by creating a local copy of the lw_shared_ptr, and get reference from it in the loop. Fixes #7605 Signed-off-by: Wojciech Mitros <wojciech.mitros@scylladb.com>