diff options
author | Alex Chronopoulos <achronop@gmail.com> | 2022-12-04 17:11:13 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-31 00:08:05 +0100 |
commit | 5f67d002a27c8dabfd84fcab4df41e578911fde6 (patch) | |
tree | d889bf1c45956a2c50cbb7d38fc31682829dce9c | |
parent | 451ae985bf3284c0c9755031656e7795a2a37144 (diff) | |
download | serenity-5f67d002a27c8dabfd84fcab4df41e578911fde6.zip |
LibAudio: Prevent int overflow in the user buffer queue
The `UserSampleQueue::remaining_samples` calculates the result by
subtracting two unsigned int numbers. That can lead to integer overflow.
Add an assert to verify that the minuend is greater or equal to the
subtrahend.
-rw-r--r-- | Userland/Libraries/LibAudio/UserSampleQueue.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Libraries/LibAudio/UserSampleQueue.cpp b/Userland/Libraries/LibAudio/UserSampleQueue.cpp index f58601849a..020cafb8b1 100644 --- a/Userland/Libraries/LibAudio/UserSampleQueue.cpp +++ b/Userland/Libraries/LibAudio/UserSampleQueue.cpp @@ -51,6 +51,7 @@ size_t UserSampleQueue::size() size_t UserSampleQueue::remaining_samples() { Threading::MutexLocker lock(m_sample_mutex); + VERIFY(m_backing_samples.size() >= m_samples_to_discard); return m_backing_samples.size() - m_samples_to_discard; } |