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

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 and applied senorblanco+haraken feedbac 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 011ddadef6d79bb5e181d30930495d8824bd4920..cdfa490f888dfb4121dd855c4ce676e85c7e8553 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
@@ -80,7 +80,14 @@ public:
void didReceiveData() override { }
void didFinishLoading() override
{
- m_PresentationConnection->didFinishLoadingBlob(m_loader.arrayBufferResult());
+ RefPtr<DOMArrayBuffer> result = m_loader.arrayBufferResultOrNull();
+ // TODO(junov): crbug.com/536816
+ // Is there a better way to handle an allocation failure instead
+ // of crashing? Would it be okay to fail silently by passing a nullptr?
+ // Should we call didFailLoadingBlob? If so, with which ErrorCode?
+ // Spec may need to be ammended for this.
+ RELEASE_ASSERT(result); // This is essentially an out-of-memory crash.
+ m_PresentationConnection->didFinishLoadingBlob(result.release());
}
void didFail(FileError::ErrorCode errorCode) override
{
@@ -207,7 +214,9 @@ void PresentationConnection::send(PassRefPtr<DOMArrayBufferView> arrayBufferView
if (!canSendMessage(exceptionState))
return;
- m_messages.append(adoptPtr(new Message(arrayBufferView->buffer())));
+ RefPtr<DOMArrayBuffer> buffer = arrayBufferView->bufferOrNull();
+ RELEASE_ASSERT(buffer); // crbug.com/536816
haraken 2015/10/29 18:58:37 Another idea would be to create bufferOrCrash(). T
Justin Novosad 2015/11/05 00:17:52 This bit of code was reverted. Getting a buffer ou
+ m_messages.append(adoptPtr(new Message(buffer)));
handleMessageQueue();
}
@@ -304,9 +313,14 @@ 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
+ // determing an accepatble alternative to crashing when buffer
haraken 2015/10/29 18:58:37 determining an acceptable
Justin Novosad 2015/11/05 00:17:52 Done.
+ // 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;
}
ASSERT_NOT_REACHED();
}

Powered by Google App Engine
This is Rietveld 408576698