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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/ConvertWebVectorToArrayBuffer.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month 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/modules/bluetooth/ConvertWebVectorToArrayBuffer.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/ConvertWebVectorToArrayBuffer.cpp b/third_party/WebKit/Source/modules/bluetooth/ConvertWebVectorToArrayBuffer.cpp
index b0e34fd6397a93683355789d13053eff78a5fd44..45a2d0ced5fff38b1d209bda7489b7ba4efed246 100644
--- a/third_party/WebKit/Source/modules/bluetooth/ConvertWebVectorToArrayBuffer.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/ConvertWebVectorToArrayBuffer.cpp
@@ -10,9 +10,14 @@ namespace blink {
PassRefPtr<DOMArrayBuffer> ConvertWebVectorToArrayBuffer::take(ScriptPromiseResolver*, const WebVector<uint8_t>& webVector)
{
static_assert(sizeof(*webVector.data()) == 1, "uint8_t should be a single byte");
-
- RefPtr<DOMArrayBuffer> domBuffer = DOMArrayBuffer::create(webVector.data(), webVector.size());
-
+ // TODO(junov): crbug.com/536816
+ // We should use DOMArrayBuffer::createOrNull here, but dealing
+ // with the null case is tricky because CallbackPromiseAdapter
+ // was not designed to allow the promise to be rejected in the success
+ // handler.
+ // The right thing to do would probably be to reject the promise with
+ // a RangeError exception when the ArrayBuffer allocation fails.
+ RefPtr<DOMArrayBuffer> domBuffer = DOMArrayBuffer::deprecatedCreateOrCrash(webVector.data(), webVector.size());
return domBuffer;
}

Powered by Google App Engine
This is Rietveld 408576698