1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 05:54:58 +00:00

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.
This commit is contained in:
Alex Chronopoulos 2022-12-04 17:11:13 +01:00 committed by Andreas Kling
parent 451ae985bf
commit 5f67d002a2

View file

@ -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;
}