Add additional protection on the write size in QAudioOuput(pulseaudio)
Check and cap the write size in pull mode to handle the case where user returned an invalid write size through QIODevice Change-Id: Ie0610a63f1d5400fba87f32a99bdc38479e0e7e8 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
@@ -371,6 +371,11 @@ void QPulseAudioOutput::userFeed()
|
||||
int audioBytesPulled = m_audioSource->read(m_audioBuffer, input);
|
||||
Q_ASSERT(audioBytesPulled <= input);
|
||||
if (audioBytesPulled > 0) {
|
||||
if (audioBytesPulled > input) {
|
||||
qWarning() << "QPulseAudioOutput::userFeed() - Invalid audio data size provided from user:"
|
||||
<< audioBytesPulled << "should be less than" << input;
|
||||
audioBytesPulled = input;
|
||||
}
|
||||
qint64 bytesWritten = write(m_audioBuffer, audioBytesPulled);
|
||||
Q_ASSERT(bytesWritten == audioBytesPulled); //unfinished write should not happen since the data provided is less than writableSize
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user