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

Unified Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.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/DocumentWebSocketChannel.cpp
diff --git a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
index 684d0769189f78cc87681f83bcded743e9ed103b..a570834943ae9393e5ae650f8eb345e371dac70e 100644
--- a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
+++ b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
@@ -100,7 +100,7 @@ void DocumentWebSocketChannel::BlobLoader::cancel()
void DocumentWebSocketChannel::BlobLoader::didFinishLoading()
{
- m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult());
+ m_channel->didFinishLoadingBlob(m_loader.arrayBufferResultOrNull());
// |this| is deleted here.
}
@@ -199,7 +199,13 @@ void DocumentWebSocketChannel::send(const DOMArrayBuffer& buffer, unsigned byteO
// buffer.slice copies its contents.
// FIXME: Reduce copy by sending the data immediately when we don't need to
// queue the data.
- m_messages.append(adoptPtr(new Message(buffer.slice(byteOffset, byteOffset + byteLength))));
+ RefPtr<DOMArrayBuffer> slice = buffer.sliceOrNull(byteOffset, byteOffset + byteLength);
+ // TODO(junov): crbug.com/536816
+ // Could we propagate a RangeError exception from here instead the
+ // following assert? Would have to edit the spec to state that exceptions
+ // thrown by ArrayBuffer allocation are re-thrown.
+ RELEASE_ASSERT(slice); // This is an out-of-memory condition.
+ m_messages.append(adoptPtr(new Message(slice.release())));
processSendQueue();
}

Powered by Google App Engine
This is Rietveld 408576698