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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.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/core/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index d124861ed419e3e543b309228fa97fa55e802566..5456e4d07f8eb4a704b37e214b609eba3766c512 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -2127,10 +2127,16 @@ bool Internals::cursorUpdatePending() const
return frame()->eventHandler().cursorUpdatePending();
}
+void Internals::fakeOutOfMemoryForNextArrayBufferAllocation() const
+{
+ WTF::ArrayBufferContents::fakeOutOfMemoryForNextArrayBufferAllocationForTesting();
+}
+
PassRefPtr<DOMArrayBuffer> Internals::serializeObject(PassRefPtr<SerializedScriptValue> value) const
{
String stringValue = value->toWireString();
- RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createUninitialized(stringValue.length(), sizeof(UChar));
+ RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createUninitializedOrNull(stringValue.length(), sizeof(UChar));
+ RELEASE_ASSERT(buffer); // Crash here means out of memory.
stringValue.copyTo(static_cast<UChar*>(buffer->data()), 0, stringValue.length());
return buffer.release();
}

Powered by Google App Engine
This is Rietveld 408576698