summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Kelly <brewkelly@gmail.com>2023-04-13 10:09:48 -0400
committerTim Flynn <trflynn89@pm.me>2023-04-14 07:13:32 -0400
commit7dd3c4a79c2a1d937eff90729bcbb6b47cb007b1 (patch)
tree6e37e8705d17a8d3e9493ef4a26393a6d2ae8c7e
parent5e3192c8d9effdc0d86e6181506f95b16d3006f8 (diff)
downloadserenity-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.cpp6
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);
}