Fix crashing data urls
authorSimon Hausmann <simon.hausmann@nokia.com>
Fri, 6 Jan 2012 12:22:13 +0000 (13:22 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 6 Jan 2012 12:41:46 +0000 (13:41 +0100)
Commit 231369eb043e9c5221da1a4f2a724643a3f380f3 introduced the use of
QBuffer::setBuffer with a QByteArray that is allocated on the stack,
causing plenty of memory corruption.

This patch replaces the use of setBuffer with setData, which correctly
assigns the QBuffer's buffer instead of just relying on the pointer
passed to setBuffer.

Spotted by Rohan in http://codereview.qt-project.org/#change,11859

Change-Id: I7cdf43d438a2a7864de7c35841b42421c1c60e68
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
src/network/access/qnetworkreplydataimpl.cpp

index 1c12ead..22f40b2 100644 (file)
@@ -78,7 +78,7 @@ QNetworkReplyDataImpl::QNetworkReplyDataImpl(QObject *parent, const QNetworkRequ
         setHeader(QNetworkRequest::ContentLengthHeader, size);
         QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
 
-        d->decodedData.setBuffer(&payload);
+        d->decodedData.setData(payload);
         d->decodedData.open(QIODevice::ReadOnly);
 
         QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,