| Index: third_party/WebKit/Source/wtf/text/CString.cpp
|
| diff --git a/third_party/WebKit/Source/wtf/text/CString.cpp b/third_party/WebKit/Source/wtf/text/CString.cpp
|
| index 4bab024171793196ad958ed0fb567e5eb5fe3e83..1a8ce0f38c8c2701f36eab40d7a57946f34204c9 100644
|
| --- a/third_party/WebKit/Source/wtf/text/CString.cpp
|
| +++ b/third_party/WebKit/Source/wtf/text/CString.cpp
|
| @@ -50,6 +50,20 @@ PassRefPtr<CStringImpl> CStringImpl::createUninitialized(size_t length,
|
| return adoptRef(new (buffer) CStringImpl(length));
|
| }
|
|
|
| +PassRefPtr<CStringImpl> CStringImpl::createUninitializedCHECK(size_t length,
|
| + char*& data) {
|
| + // TODO(esprehn): This doesn't account for the NUL.
|
| + CHECK_LT(length, (numeric_limits<unsigned>::max() - sizeof(CStringImpl)));
|
| +
|
| + // The +1 is for the terminating NUL character.
|
| + size_t size = sizeof(CStringImpl) + length + 1;
|
| + CStringImpl* buffer = static_cast<CStringImpl*>(
|
| + Partitions::bufferMalloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringImpl)));
|
| + data = reinterpret_cast<char*>(buffer + 1);
|
| + data[length] = '\0';
|
| + return adoptRef(new (buffer) CStringImpl(length));
|
| +}
|
| +
|
| void CStringImpl::operator delete(void* ptr) {
|
| Partitions::bufferFree(ptr);
|
| }
|
| @@ -60,7 +74,11 @@ CString::CString(const char* chars, size_t length) {
|
| return;
|
| }
|
| char* data;
|
| - m_buffer = CStringImpl::createUninitialized(length, data);
|
| + if (rand() % 2) {
|
| + m_buffer = CStringImpl::createUninitialized(length, data);
|
| + } else {
|
| + m_buffer = CStringImpl::createUninitializedCHECK(length, data);
|
| + }
|
| memcpy(data, chars, length);
|
| }
|
|
|
|
|