Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Unified Diff: third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp
diff --git a/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp b/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp
index f68c76779941577de2f63eb62323949d601ffe41..d3f512f33d8a7ce13d1b866695637c77768fa12d 100644
--- a/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp
+++ b/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp
@@ -638,7 +638,12 @@ void DOMWebSocket::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> binaryData)
}
case BinaryTypeArrayBuffer:
- RefPtr<DOMArrayBuffer> arrayBuffer = DOMArrayBuffer::create(binaryData->data(), binaryData->size());
+ // TODO(junov): crbug.com/536816
+ // Avoid crashing when out of memory by using createOrNull(). Requires
+ // determining appropriate alternate behavior for dealing with allocation
+ // failures. Should the event be dropped? Should we dispatch an event
+ // with null data? Should we dispatch some kind of failure code?
+ RefPtr<DOMArrayBuffer> arrayBuffer = DOMArrayBuffer::deprecatedCreateOrCrash(binaryData->data(), binaryData->size());
Platform::current()->histogramEnumeration("WebCore.WebSocket.ReceiveType", WebSocketReceiveTypeArrayBuffer, WebSocketReceiveTypeMax);
m_eventQueue->dispatch(MessageEvent::create(arrayBuffer.release(), SecurityOrigin::create(m_url)->toString()));
break;

Powered by Google App Engine
This is Rietveld 408576698