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

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: 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/presentation/PresentationConnection.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
index 011ddadef6d79bb5e181d30930495d8824bd4920..2471a6bcd31917c4cb4ab28e92fa303a4429e415 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
@@ -80,7 +80,7 @@ public:
void didReceiveData() override { }
void didFinishLoading() override
{
- m_PresentationConnection->didFinishLoadingBlob(m_loader.arrayBufferResult());
+ m_PresentationConnection->didFinishLoadingBlob(m_loader.arrayBufferResultOrNull());
}
void didFail(FileError::ErrorCode errorCode) override
{
@@ -207,7 +207,8 @@ void PresentationConnection::send(PassRefPtr<DOMArrayBufferView> arrayBufferView
if (!canSendMessage(exceptionState))
return;
- m_messages.append(adoptPtr(new Message(arrayBufferView->buffer())));
+ RefPtr<DOMArrayBuffer> buffer = arrayBufferView->buffer();
+ m_messages.append(adoptPtr(new Message(buffer)));
handleMessageQueue();
}
@@ -304,7 +305,13 @@ void PresentationConnection::didReceiveBinaryMessage(const uint8_t* data, size_t
return;
}
case BinaryTypeArrayBuffer:
- RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, length);
+ // TODO(junov): crbug.com/536816
+ // Use createOrNull instead of deprecatedCReateOrCrash. Requires
+ // determining an acceptable alternative to crashing when buffer
+ // allocation fails. Should we just drop the event? Dispatch
+ // an event with null data? Dispatch some kind of error code?
+ // Behavior needs to be defined in the spec.
+ RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::deprecatedCreateOrCrash(data, length);
dispatchEvent(MessageEvent::create(buffer.release()));
return;
}

Powered by Google App Engine
This is Rietveld 408576698