Remote web inspector reentrancy fixes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 15:11:37 +0000 (15:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 15:11:37 +0000 (15:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77022

Patch by Leo Franchi <lfranchi@kde.org> on 2012-02-08
Reviewed by Joseph Pecoraro.

* WebCoreSupport/InspectorServerQt.cpp:
(WebCore::InspectorServerRequestHandlerQt::tcpReadyRead):
(WebCore::InspectorServerRequestHandlerQt::webSocketReadyRead):

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

Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp

index caab4e6..9406c92 100644 (file)
@@ -1,3 +1,14 @@
+2012-02-08  Leo Franchi  <lfranchi@kde.org>
+
+        Remote web inspector reentrancy fixes
+        https://bugs.webkit.org/show_bug.cgi?id=77022
+
+        Reviewed by Joseph Pecoraro.
+
+        * WebCoreSupport/InspectorServerQt.cpp:
+        (WebCore::InspectorServerRequestHandlerQt::tcpReadyRead):
+        (WebCore::InspectorServerRequestHandlerQt::webSocketReadyRead):
+
 2012-02-06  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
 
         Provide more attribute methods in Element
index fdc14f5..26c52ff 100644 (file)
@@ -209,7 +209,7 @@ void InspectorServerRequestHandlerQt::tcpReadyRead()
             // switch to websocket-style WebSocketService messaging
             if (m_tcpConnection) {
                 m_tcpConnection->disconnect(SIGNAL(readyRead()));
-                connect(m_tcpConnection, SIGNAL(readyRead()), SLOT(webSocketReadyRead()));
+                connect(m_tcpConnection, SIGNAL(readyRead()), SLOT(webSocketReadyRead()), Qt::QueuedConnection);
 
                 QByteArray key3 = m_tcpConnection->read(8);
 
@@ -357,6 +357,10 @@ void InspectorServerRequestHandlerQt::webSocketReadyRead()
 
         QByteArray payload = m_data.mid(1, length);
 
+        // Remove this WebSocket message from m_data (payload, start-of-frame byte, end-of-frame byte).
+        // Truncate data before delivering message in case of re-entrancy.
+        m_data = m_data.mid(length + 2);
+        
 #if ENABLE(INSPECTOR)
         if (m_inspectorClient) {
           InspectorController* inspectorController = m_inspectorClient->m_inspectedWebPage->d->page->inspectorController();
@@ -364,8 +368,6 @@ void InspectorServerRequestHandlerQt::webSocketReadyRead()
         }
 #endif
 
-        // Remove this WebSocket message from m_data (payload, start-of-frame byte, end-of-frame byte).
-        m_data = m_data.mid(length + 2);
     }
 }