| Index: Source/wtf/ArrayBufferContents.cpp
|
| diff --git a/Source/wtf/ArrayBufferContents.cpp b/Source/wtf/ArrayBufferContents.cpp
|
| index 2d03a4107e9fc6fee62e13be1ee3dada0c297b12..4b29a8212d889614e5bb99991c87f5f133c34526 100644
|
| --- a/Source/wtf/ArrayBufferContents.cpp
|
| +++ b/Source/wtf/ArrayBufferContents.cpp
|
| @@ -59,6 +59,7 @@ ArrayBufferContents::ArrayBufferContents(
|
| {
|
| if (data) {
|
| m_holder->adopt(data, sizeInBytes, isShared);
|
| + m_holder->setAllocated(false);
|
| } else {
|
| ASSERT(!sizeInBytes);
|
| sizeInBytes = 0;
|
| @@ -116,16 +117,19 @@ void ArrayBufferContents::freeMemory(void* data, size_t size)
|
|
|
| ArrayBufferContents::DataHolder::DataHolder()
|
| : m_data(nullptr)
|
| + , m_malloc(false)
|
| , m_sizeInBytes(0)
|
| , m_isShared(NotShared) { }
|
|
|
| ArrayBufferContents::DataHolder::~DataHolder()
|
| {
|
| - ArrayBufferContents::freeMemory(m_data, m_sizeInBytes);
|
| + if (m_malloc)
|
| + ArrayBufferContents::freeMemory(m_data, m_sizeInBytes);
|
|
|
| m_data = nullptr;
|
| m_sizeInBytes = 0;
|
| m_isShared = NotShared;
|
| + m_malloc = false;
|
| }
|
|
|
| void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes, SharingType isShared, InitializationPolicy policy)
|
| @@ -136,6 +140,7 @@ void ArrayBufferContents::DataHolder::allocateNew(unsigned sizeInBytes, SharingT
|
| m_data = data;
|
| m_sizeInBytes = data ? sizeInBytes : 0;
|
| m_isShared = isShared;
|
| + m_malloc = true;
|
| }
|
|
|
| void ArrayBufferContents::DataHolder::adopt(void* data, unsigned sizeInBytes, SharingType isShared)
|
|
|