Commit afadc21a authored by binji@chromium.org's avatar binji@chromium.org

Set ArrayBufferContents size to 0 on allocation failure

Also, add a RELEASE_ASSERT when creating an ArrayBuffer from an
ArrayBufferContents that the backing store is non-NULL.

BUG=522128

Review URL: https://codereview.chromium.org/1302193002

git-svn-id: svn://svn.chromium.org/blink/trunk@200961 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 469e84e6
...@@ -122,6 +122,7 @@ PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLen ...@@ -122,6 +122,7 @@ PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLen
PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents) PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents)
{ {
RELEASE_ASSERT(contents.data());
return adoptRef(new ArrayBuffer(contents)); return adoptRef(new ArrayBuffer(contents));
} }
......
...@@ -134,7 +134,7 @@ void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes, SharingT ...@@ -134,7 +134,7 @@ void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes, SharingT
void* data = nullptr; void* data = nullptr;
allocateMemory(sizeInBytes, policy, data); allocateMemory(sizeInBytes, policy, data);
m_data = data; m_data = data;
m_sizeInBytes = sizeInBytes; m_sizeInBytes = data ? sizeInBytes : 0;
m_isShared = isShared; m_isShared = isShared;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment