From cee992cdd65e53d2efc2069b1f64daabf97efea6 Mon Sep 17 00:00:00 2001 From: hawcroft Date: Mon, 10 Oct 2011 13:55:02 +1000 Subject: [PATCH] bail out in case of missing descriptors Change-Id: I7c231367a4b5ef2d15fd1a7af2c2a6c1d51c9460 Reviewed-on: http://codereview.qt-project.org/6279 Sanity-Review: Qt Sanity Bot Reviewed-by: Jonas Rabbe Reviewed-by: Michael Goddard --- src/multimedia/effects/qwavedecoder_p.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/multimedia/effects/qwavedecoder_p.cpp b/src/multimedia/effects/qwavedecoder_p.cpp index 19b262ad..e173aed8 100644 --- a/src/multimedia/effects/qwavedecoder_p.cpp +++ b/src/multimedia/effects/qwavedecoder_p.cpp @@ -106,6 +106,7 @@ qint64 QWaveDecoder::writeData(const char *data, qint64 len) void QWaveDecoder::handleData() { + bool valid = true; if (state == QWaveDecoder::InitialState) { if (source->bytesAvailable() < qint64(sizeof(RIFFHeader))) return; @@ -125,7 +126,7 @@ void QWaveDecoder::handleData() } if (state == QWaveDecoder::WaitingForFormatState) { - if (findChunk("fmt ")) { + if (valid = findChunk("fmt ")) { chunk descriptor; source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); @@ -158,7 +159,7 @@ void QWaveDecoder::handleData() } if (state == QWaveDecoder::WaitingForDataState) { - if (findChunk("data")) { + if (valid = findChunk("data")) { source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); chunk descriptor; @@ -173,7 +174,7 @@ void QWaveDecoder::handleData() } } - if (source->atEnd()) { + if (source->atEnd() || !valid) { source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); emit invalidFormat();