Index: Source/platform/SharedBuffer.cpp |
diff --git a/Source/platform/SharedBuffer.cpp b/Source/platform/SharedBuffer.cpp |
index f6cf3dc50d0e9f6b4dff0f2da99192fdeadd1e54..6594e7a9997651a24686ef91301fa8b1ee85bfcd 100644 |
--- a/Source/platform/SharedBuffer.cpp |
+++ b/Source/platform/SharedBuffer.cpp |
@@ -386,7 +386,8 @@ PassRefPtr<ArrayBuffer> SharedBuffer::getAsArrayBuffer() const |
PassRefPtr<SkData> SharedBuffer::getAsSkData() const |
{ |
unsigned bufferLength = size(); |
- char* buffer = static_cast<char*>(sk_malloc_throw(bufferLength)); |
+ SkData* data = SkData::NewUninitialized(bufferLength); |
+ char* buffer = static_cast<char*>(data->writable_data()); |
const char* segment = 0; |
unsigned position = 0; |
while (unsigned segmentSize = getSomeData(segment, position)) { |
@@ -399,7 +400,7 @@ PassRefPtr<SkData> SharedBuffer::getAsSkData() const |
// Don't return the incomplete SkData. |
return nullptr; |
} |
- return adoptRef(SkData::NewFromMalloc(buffer, bufferLength)); |
+ return adoptRef(data); |
} |
bool SharedBuffer::lock() |