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

Unified Diff: third_party/WebKit/Source/core/dom/DOMTypedArray.h

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/core/dom/DOMTypedArray.h
diff --git a/third_party/WebKit/Source/core/dom/DOMTypedArray.h b/third_party/WebKit/Source/core/dom/DOMTypedArray.h
index e8ea244f2d0bf12225cd317cbcf36dd025915ecb..45b0e0eca8d462b976402888865b475f77580310 100644
--- a/third_party/WebKit/Source/core/dom/DOMTypedArray.h
+++ b/third_party/WebKit/Source/core/dom/DOMTypedArray.h
@@ -29,17 +29,24 @@ class CORE_TEMPLATE_CLASS_EXPORT DOMTypedArray final : public DOMArrayBufferView
public:
typedef typename WTFTypedArray::ValueType ValueType;
+ static PassRefPtr<ThisType> createOrNull(PassRefPtr<WTFTypedArray> bufferView)
+ {
+ if (!bufferView)
+ return nullptr;
+ return adoptRef(new ThisType(bufferView));
+ }
static PassRefPtr<ThisType> create(PassRefPtr<WTFTypedArray> bufferView)
{
+ RELEASE_ASSERT(bufferView);
return adoptRef(new ThisType(bufferView));
}
- static PassRefPtr<ThisType> create(unsigned length)
+ static PassRefPtr<ThisType> createOrNull(const ValueType* array, unsigned length)
{
- return create(WTFTypedArray::create(length));
+ return createOrNull(WTFTypedArray::createOrNull(array, length));
}
- static PassRefPtr<ThisType> create(const ValueType* array, unsigned length)
+ static PassRefPtr<ThisType> deprecatedCreateOrCrash(const ValueType* array, unsigned length)
{
- return create(WTFTypedArray::create(array, length));
+ return create(WTFTypedArray::deprecatedCreateOrCrash(array, length));
}
static PassRefPtr<ThisType> create(PassRefPtr<WTF::ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
{
@@ -58,6 +65,13 @@ public:
return buffer ? create(buffer.release(), 0, length) : nullptr;
}
+ static PassRefPtr<ThisType> deprecatedCreateOrCrash(unsigned length)
+ {
+ RefPtr<WTF::ArrayBuffer> buffer = WTF::ArrayBuffer::deprecatedCreateOrCrash(length, 1);
binji 2015/10/16 22:12:39 what is the 1 here? Ah, element size. Seems weird
Justin Novosad 2015/10/19 16:42:52 Acknowledged.
+ ASSERT(buffer);
+ return create(buffer.release(), 0, length);
+ }
+
const WTFTypedArray* view() const { return static_cast<const WTFTypedArray*>(DOMArrayBufferView::view()); }
WTFTypedArray* view() { return static_cast<WTFTypedArray*>(DOMArrayBufferView::view()); }

Powered by Google App Engine
This is Rietveld 408576698