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

Unified Diff: third_party/WebKit/Source/modules/crypto/CryptoResultImpl.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/crypto/CryptoResultImpl.cpp
diff --git a/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp b/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp
index 7efd0097e99174319967326f84ecda015b77219b..fc9352a65774a9d50064cfc4a0adb6458a2cb94a 100644
--- a/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp
+++ b/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp
@@ -181,7 +181,21 @@ void CryptoResultImpl::completeWithBuffer(const void* bytes, unsigned bytesSize)
if (!m_resolver)
return;
- m_resolver->resolve(DOMArrayBuffer::create(bytes, bytesSize));
+ // TODO(junov): crbug.com/536816
+ // Instead of crashing when array buffer allocation fails, we could
+ // and probably should use DOMArrayBuffer::createOrNull and reject
+ // the promise with a RangeError exception when creation returns null.
+ // The specs for all crypto methods that use this code state: "If the
+ // following steps or referenced procedures say to throw an error,
+ // reject promise with the returned error and then terminate the algorithm."
+ // In this case, the procedure of allocating an ArrayBuffer is not explicitly
+ // referenced in the algorithms laid out in the spec, but one could argue
+ // that it is implied, and the ECMAScript spec says that failure to
+ // allocate the buffer should result in a RangeError being thrown.
+ // http://ecma-international.org/ecma-262/6.0/#sec-createbytedatablock
+ // The crypto spec probably needs to be edited to be more explicit about
+ // this issue.
+ m_resolver->resolve(DOMArrayBuffer::deprecatedCreateOrCrash(bytes, bytesSize));
clearResolver();
}

Powered by Google App Engine
This is Rietveld 408576698