From d6f28d456c6ec5ecf39c868447d85294a698166d Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Wed, 12 Jul 2023 23:51:00 +0200 Subject: [PATCH] fix: Prevent crash in GetEarliestTimestamp() if periods are empty (#1173) While I have not yet found why the periods are empty, this will prevent shaka from seg faulting Fixes #1172 --- packager/mpd/base/mpd_builder.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index f09381601e..e2241dc2e3 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -342,6 +342,8 @@ float MpdBuilder::GetStaticMpdDuration() { bool MpdBuilder::GetEarliestTimestamp(double* timestamp_seconds) { DCHECK(timestamp_seconds); DCHECK(!periods_.empty()); + if (periods_.empty()) + return false; double timestamp = 0; double earliest_timestamp = -1; // TODO(kqyang): This is used to set availabilityStartTime. We may consider