summaryrefslogtreecommitdiff
path: root/Userland/Applications/SoundPlayer
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-09-03 18:49:38 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-04 03:28:33 +0200
commitd81ba98976c68c52ead7feb5ce352797ddca6b68 (patch)
tree2580dbd145f70b23da6eec18ab62187e5b06d51a /Userland/Applications/SoundPlayer
parent0139a56aa517182813084cf3efc07a72c29a80ed (diff)
downloadserenity-d81ba98976c68c52ead7feb5ce352797ddca6b68.zip
SoundPlayer: Don't try to dereference null-pointer buffers
d049626f402f50720a1ccc4452676a56e22debbd tried to resample the buffer before checking if it points to a valid location. This caused a crash, generally at the end of the file.
Diffstat (limited to 'Userland/Applications/SoundPlayer')
-rw-r--r--Userland/Applications/SoundPlayer/PlaybackManager.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp
index 74a041cab2..2d8592dd71 100644
--- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp
+++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp
@@ -118,10 +118,11 @@ void PlaybackManager::next_buffer()
if (audio_server_remaining_samples < m_device_samples_per_buffer) {
m_current_buffer = m_loader->get_more_samples(m_source_buffer_size_bytes);
- VERIFY(m_resampler.has_value());
- m_resampler->reset();
- m_current_buffer = Audio::resample_buffer(m_resampler.value(), *m_current_buffer);
- if (m_current_buffer)
+ if (m_current_buffer) {
+ VERIFY(m_resampler.has_value());
+ m_resampler->reset();
+ m_current_buffer = Audio::resample_buffer(m_resampler.value(), *m_current_buffer);
m_connection->enqueue(*m_current_buffer);
+ }
}
}