Fix overflow bug in Haiku frontend when the playback position ends up larger than the length

This commit is contained in:
Zachary Hall 2025-01-21 12:46:53 -08:00
parent c2a971d225
commit 82c3a77f51

View file

@ -333,7 +333,9 @@ void HaikuLooperWindow::Pulse() {
auto len = playback->GetLength();
auto pos = playback->GetPosition();
auto pos_milliseconds = pos * 1000.0;
int32_t pos_int32 = (int32_t)((((int64_t)pos_milliseconds) * INT32_MAX) / 1000 / len);
int64_t pos_int64 = (((int64_t)pos_milliseconds) * INT32_MAX) / 1000 / len;
if (pos_int64 > INT32_MAX) pos_int64 = INT32_MAX;
int32_t pos_int32 = (int32_t)pos_int64;
if (!seek_clicked) slider->SetValue(pos_int32);
auto component_count = TimeToComponentCount(len);
bool enable_ui = !playback->IsStopped();