summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-10-28 22:28:14 +0200
committerCarl Hetherington <cth@carlh.net>2023-10-28 22:28:14 +0200
commit6ab77878f2bef6ece4da8be4307d4b05922e21d6 (patch)
tree281f90ce8afc30a5c609c2d029078d1b577f3c75
parentb64154929cefc91fa8da08fa0a089994387a2553 (diff)
Fix possible dereference of invalid iterator (if have_pushed is empty).
-rw-r--r--src/lib/player.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 40773e250..ef7ecde5a 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -832,17 +832,18 @@ Player::pass ()
[](state_pair const& a, state_pair const& b) { return a.second.last_push_end.get() < b.second.last_push_end.get(); }
);
+ std::map<AudioStreamPtr, StreamState> alive_stream_states;
+
if (latest_last_push_end != have_pushed.end()) {
LOG_DEBUG_PLAYER("Leading audio stream is in %1 at %2", latest_last_push_end->second.piece->content->path(0), to_string(latest_last_push_end->second.last_push_end.get()));
- }
- /* Now make a list of those streams that are less than ignore_streams_behind behind the leader */
- std::map<AudioStreamPtr, StreamState> alive_stream_states;
- for (auto const& i: _stream_states) {
- if (!i.second.last_push_end || (latest_last_push_end->second.last_push_end.get() - i.second.last_push_end.get()) < dcpomatic::DCPTime::from_seconds(ignore_streams_behind)) {
- alive_stream_states.insert(i);
- } else {
- LOG_DEBUG_PLAYER("Ignoring stream %1 because it is too far behind", i.second.piece->content->path(0));
+ /* Now make a list of those streams that are less than ignore_streams_behind behind the leader */
+ for (auto const& i: _stream_states) {
+ if (!i.second.last_push_end || (latest_last_push_end->second.last_push_end.get() - i.second.last_push_end.get()) < dcpomatic::DCPTime::from_seconds(ignore_streams_behind)) {
+ alive_stream_states.insert(i);
+ } else {
+ LOG_DEBUG_PLAYER("Ignoring stream %1 because it is too far behind", i.second.piece->content->path(0));
+ }
}
}