13
0

Do not modify read-only RCU copy of routelist

RCU reader returns a shared ptr to the current object which
can also be used in other places at the same time.

Sorting the shared-ptr list invalidates iterators which can
throw off other users of the same object.

This fixes a bug in PT-import which calls get_nth_audio_track().
This commit is contained in:
Robin Gareus 2023-04-07 19:37:30 +02:00
parent 979f9876a7
commit f3e13848fa
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -6408,11 +6408,11 @@ Session::route_removed_from_route_group (RouteGroup* rg, std::weak_ptr<Route> r)
std::shared_ptr<AudioTrack>
Session::get_nth_audio_track (uint32_t nth) const
{
std::shared_ptr<RouteList> rl = routes.reader ();
rl->sort (Stripable::Sorter ());
RouteList rl (*(routes.reader ()));
rl.sort (Stripable::Sorter());
for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
std::shared_ptr<AudioTrack> at = std::dynamic_pointer_cast<AudioTrack> (*r);
for (auto const& r: rl) {
std::shared_ptr<AudioTrack> at = std::dynamic_pointer_cast<AudioTrack> (r);
if (!at) {
continue;
}