-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix integer overflow calculating length of very large playlists #2116
Fix integer overflow calculating length of very large playlists #2116
Conversation
3ce06ad
to
cfc5bfa
Compare
This loses type safety by downgrading from std::chrono to raw integers, but what do these raw integers mean? You make the core more obscure and less safe. |
88eb713
to
80431be
Compare
Ok, migrated it to std::chrono::duration api. |
src/playlist/Length.cxx
Outdated
const auto seconds = std::chrono::duration_cast<std::chrono::seconds>(playtime); | ||
r.Fmt(FMT_STRING("playtime: {}\n"), seconds.count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the rounding which was very explicit previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with std::chrono::round
@@ -21,7 +21,7 @@ | |||
|
|||
static SignedSongTime get_duration(const DetachedSong &song) { | |||
const auto duration = song.GetDuration(); | |||
return duration.IsNegative() ? (SignedSongTime)0 : song.GetDuration(); | |||
return duration.IsNegative() ? (SignedSongTime)0 : duration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I get the song duration in the local variable there is no need to call the GetDuration function a second time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but it doesn't fix an integer overflow
80431be
to
052719c
Compare
No description provided.