Fix integer overflow calculating length of very large playlists
This commit is contained in:
parent
a3a07280e8
commit
052719c0e4
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
static SignedSongTime get_duration(const DetachedSong &song) {
|
static SignedSongTime get_duration(const DetachedSong &song) {
|
||||||
const auto duration = song.GetDuration();
|
const auto duration = song.GetDuration();
|
||||||
return duration.IsNegative() ? (SignedSongTime)0 : song.GetDuration();
|
return duration.IsNegative() ? (SignedSongTime)0 : duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -36,7 +36,7 @@ playlist_provider_length(Response &r,
|
||||||
|
|
||||||
std::unique_ptr<DetachedSong> song;
|
std::unique_ptr<DetachedSong> song;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
SignedSongTime playtime = (SignedSongTime)0;
|
std::chrono::milliseconds playtime = (std::chrono::milliseconds)0;
|
||||||
while ((song = e.NextSong()) != nullptr) {
|
while ((song = e.NextSong()) != nullptr) {
|
||||||
if (playlist_check_translate_song(*song, base_uri,
|
if (playlist_check_translate_song(*song, base_uri,
|
||||||
loader))
|
loader))
|
||||||
|
@ -44,7 +44,8 @@ playlist_provider_length(Response &r,
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
r.Fmt(FMT_STRING("songs: {}\n"), i);
|
r.Fmt(FMT_STRING("songs: {}\n"), i);
|
||||||
r.Fmt(FMT_STRING("playtime: {}\n"), playtime.RoundS());
|
const auto seconds = std::chrono::round<std::chrono::seconds>(playtime);
|
||||||
|
r.Fmt(FMT_STRING("playtime: {}\n"), seconds.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue