Fix crashes in the new networking code.
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2008 09:38:40 +0000 (09:38 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2008 09:38:40 +0000 (09:38 +0000)
When the ResourceLoader cancels the handle we have to make sure not to access
the resource handle afterwards again.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29515 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/network/qt/QNetworkReplyHandler.cpp

index 1a087b7..122103a 100644 (file)
@@ -1,3 +1,16 @@
+2008-01-16  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Lars Knoll <lars@trolltech.com>.
+
+        Fix crashes in the new networking code.
+
+        When the ResourceLoader cancels the handle we have to make sure not to access
+        the resource handle afterwards again.
+
+        * platform/network/qt/QNetworkReplyHandler.cpp:
+        (WebCore::QNetworkReplyHandler::finish):
+        (WebCore::QNetworkReplyHandler::forwardData):
+
 2008-01-16  Lars Knoll  <lars@trolltech.com>
 
         Reviewed by Simon.
index 8990d4d..e33077e 100644 (file)
@@ -66,6 +66,7 @@ QNetworkReplyHandler::QNetworkReplyHandler(ResourceHandle *handle)
 
 void QNetworkReplyHandler::abort()
 {
+    m_resourceHandle = 0;
     if (m_reply) {
         disconnect(m_reply, 0, this, 0);
         m_reply->abort();
@@ -77,6 +78,8 @@ void QNetworkReplyHandler::finish()
 {
     sendResponseIfNeeded();
 
+    if (!m_resourceHandle)
+        return;
     ResourceHandleClient* client = m_resourceHandle->client();
     m_reply->deleteLater();
     if (!client)
@@ -96,7 +99,7 @@ void QNetworkReplyHandler::finish()
 
 void QNetworkReplyHandler::sendResponseIfNeeded()
 {
-    if (m_responseSent)
+    if (m_responseSent || !m_resourceHandle)
         return;
     m_responseSent = true;
 
@@ -163,6 +166,9 @@ void QNetworkReplyHandler::forwardData()
     if (m_redirected)
         return;
 
+    if (!m_resourceHandle)
+        return;
+
     QByteArray data = m_reply->read(m_reply->bytesAvailable());
 
     ResourceHandleClient* client = m_resourceHandle->client();