http/tests/websocket/tests/hybi/stop-on-resume-in-error-handler.html crashes on Windo...
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 May 2016 18:44:38 +0000 (18:44 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 May 2016 18:44:38 +0000 (18:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144057

Patch by Per Arne Vollan <pvollan@apple.com> on 2016-05-30
Reviewed by Brent Fulgham.

Protect SocketStreamHandle object before trying to access it on the main thread, and make sure
CFWriteStreamRef parameter is valid before calling CFWriteStreamCanAcceptBytes.

* platform/network/cf/SocketStreamHandleCFNet.cpp:
(WebCore::SocketStreamHandle::readStreamCallback):
(WebCore::SocketStreamHandle::writeStreamCallback):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp

index bcd01b3..953bde9 100644 (file)
@@ -1,3 +1,17 @@
+2016-05-30  Per Arne Vollan  <pvollan@apple.com>
+
+        http/tests/websocket/tests/hybi/stop-on-resume-in-error-handler.html crashes on Windows almost all the time
+        https://bugs.webkit.org/show_bug.cgi?id=144057
+
+        Reviewed by Brent Fulgham.
+
+        Protect SocketStreamHandle object before trying to access it on the main thread, and make sure
+        CFWriteStreamRef parameter is valid before calling CFWriteStreamCanAcceptBytes. 
+
+        * platform/network/cf/SocketStreamHandleCFNet.cpp:
+        (WebCore::SocketStreamHandle::readStreamCallback):
+        (WebCore::SocketStreamHandle::writeStreamCallback):
+
 2016-05-30  Javier Fernandez  <jfernandez@igalia.com>
 
         [CSS Box Alignment] New CSS Value 'normal' for Self Alignment
index 3ba03f1..7365cf4 100644 (file)
@@ -448,8 +448,10 @@ void SocketStreamHandle::readStreamCallback(CFReadStreamRef stream, CFStreamEven
         return;
 
 #if PLATFORM(WIN)
+    RefPtr<SocketStreamHandle> protector(handle);
     callOnMainThreadAndWait([&] {
-        handle->readStreamCallback(type);
+        if (handle->m_readStream)
+            handle->readStreamCallback(type);
     });
 #else
     ASSERT(isMainThread());
@@ -466,8 +468,10 @@ void SocketStreamHandle::writeStreamCallback(CFWriteStreamRef stream, CFStreamEv
         return;
 
 #if PLATFORM(WIN)
+    RefPtr<SocketStreamHandle> protector(handle);
     callOnMainThreadAndWait([&] {
-        handle->writeStreamCallback(type);
+        if (handle->m_writeStream)
+            handle->writeStreamCallback(type);
     });
 #else
     ASSERT(isMainThread());