diff options
author | Brendan Kelly <brewkelly@gmail.com> | 2023-04-13 10:09:48 -0400 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-04-14 07:13:32 -0400 |
commit | 7dd3c4a79c2a1d937eff90729bcbb6b47cb007b1 (patch) | |
tree | 6e37e8705d17a8d3e9493ef4a26393a6d2ae8c7e | |
parent | 5e3192c8d9effdc0d86e6181506f95b16d3006f8 (diff) | |
download | serenity-7dd3c4a79c2a1d937eff90729bcbb6b47cb007b1.zip |
SoundPlayer: Check if loader is null
This patch prevents SoundPlayer from crashing when attempting to "seek"
when no file has been loaded
-rw-r--r-- | Userland/Applications/SoundPlayer/Player.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp index 41c874cdd0..fcc5a2d09d 100644 --- a/Userland/Applications/SoundPlayer/Player.cpp +++ b/Userland/Applications/SoundPlayer/Player.cpp @@ -155,7 +155,11 @@ void Player::toggle_mute() void Player::seek(int sample) { - sample *= (m_playback_manager.device_sample_rate() / static_cast<float>(m_playback_manager.loader()->sample_rate())); + auto loader = m_playback_manager.loader(); + if (loader.is_null()) { + return; + } + sample *= (m_playback_manager.device_sample_rate() / static_cast<float>(loader->sample_rate())); m_playback_manager.seek(sample); } |