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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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/presentation/PresentationConnection.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
index b262989882dd4ea2ba48c0107d01fa74a32fdb18..f8df5665adf5a5d3438f6e67516df683dcd07a6e 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
@@ -203,11 +203,11 @@ void PresentationConnection::send(PassRefPtr<DOMArrayBuffer> arrayBuffer, Except
void PresentationConnection::send(PassRefPtr<DOMArrayBufferView> arrayBufferView, ExceptionState& exceptionState)
{
- ASSERT(arrayBufferView);
+ ASSERT(arrayBufferView && arrayBufferView->bufferOrNull());
if (!canSendMessage(exceptionState))
return;
- m_messages.append(adoptPtr(new Message(arrayBufferView->buffer())));
+ m_messages.append(adoptPtr(new Message(arrayBufferView->bufferOrNull())));
handleMessageQueue();
}
@@ -304,9 +304,11 @@ void PresentationConnection::didReceiveBinaryMessage(const uint8_t* data, size_t
return;
}
case BinaryTypeArrayBuffer:
- RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, length);
- dispatchEvent(MessageEvent::create(buffer.release()));
- return;
+ RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createOrNull(data, length);
+ // Can't throw a RangeError exception from here, so being out
+ // of memory will fail silently by dropping the message.
+ if (buffer)
+ dispatchEvent(MessageEvent::create(buffer.release()));
}
ASSERT_NOT_REACHED();
}

Powered by Google App Engine
This is Rietveld 408576698