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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: applied review comments 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/bindings/core/v8/ScriptValueSerializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
index 3bd0390146d9043f971387b6fb751005509455e8..7bf3c65832408e2f127e66aefb5cb257dad8ae50 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
@@ -976,10 +976,10 @@ ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer
ASSERT(!object.IsEmpty());
DOMArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(object);
if (!arrayBufferView)
- return 0;
- if (!arrayBufferView->bufferBase())
+ return nullptr;
+ if (!arrayBufferView->bufferBaseOrNull())
return handleError(DataCloneError, "An ArrayBuffer could not be cloned.", next);
- v8::Local<v8::Value> underlyingBuffer = toV8(arrayBufferView->bufferBase(), m_scriptState->context()->Global(), isolate());
+ v8::Local<v8::Value> underlyingBuffer = toV8(arrayBufferView->bufferBaseOrNull(), m_scriptState->context()->Global(), isolate());
if (underlyingBuffer.IsEmpty())
return handleError(DataCloneError, "An ArrayBuffer could not be cloned.", next);
StateBase* stateOut = doSerializeArrayBuffer(underlyingBuffer, next);
@@ -1532,7 +1532,10 @@ bool SerializedScriptValueReader::readImageData(v8::Local<v8::Value>* value)
return false;
if (m_position + pixelDataLength > m_length)
return false;
- ImageData* imageData = ImageData::create(IntSize(width, height));
+ NonThrowableExceptionState exceptionState;
+ ImageData* imageData = ImageData::create(IntSize(width, height), exceptionState);
+ if (exceptionState.hadException())
+ return false;
DOMUint8ClampedArray* pixelArray = imageData->data();
ASSERT(pixelArray);
ASSERT(pixelArray->length() >= pixelDataLength);
@@ -1556,7 +1559,7 @@ bool SerializedScriptValueReader::readCompositorProxy(v8::Local<v8::Value>* valu
return !value->IsEmpty();
}
-PassRefPtr<DOMArrayBuffer> SerializedScriptValueReader::doReadArrayBuffer()
+PassRefPtr<DOMArrayBuffer> SerializedScriptValueReader::doReadArrayBufferOrNull()
jsbell 2015/10/20 22:25:50 Since this already returned nullptr in some cases,
{
uint32_t byteLength;
if (!doReadUint32(&byteLength))
@@ -1565,12 +1568,12 @@ PassRefPtr<DOMArrayBuffer> SerializedScriptValueReader::doReadArrayBuffer()
return nullptr;
const void* bufferStart = m_buffer + m_position;
m_position += byteLength;
- return DOMArrayBuffer::create(bufferStart, byteLength);
+ return DOMArrayBuffer::createOrNull(bufferStart, byteLength);
}
bool SerializedScriptValueReader::readArrayBuffer(v8::Local<v8::Value>* value)
{
- RefPtr<DOMArrayBuffer> arrayBuffer = doReadArrayBuffer();
+ RefPtr<DOMArrayBuffer> arrayBuffer = doReadArrayBufferOrNull();
if (!arrayBuffer)
return false;
jsbell 2015/10/20 22:25:50 I'm embarrassed to say I don't know how we handle
*value = toV8(arrayBuffer.release(), m_scriptState->context()->Global(), isolate());

Powered by Google App Engine
This is Rietveld 408576698