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

Unified Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 2730943002: XMLHttpRequest: return null upon failing responseArrayBuffer allocation. (Closed)
Patch Set: Created 3 years, 10 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/xmlhttprequest/XMLHttpRequest.cpp
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
index eae72e1e03323bca9e761c5068e30b3531e7451d..9ad95f53681a388ce38c6a8c8e4a161a2cb9c32a 100644
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -387,11 +387,16 @@ DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() {
if (!m_responseArrayBuffer) {
if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) {
- DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitialized(
+ DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitializedOrNull(
m_binaryResponseBuilder->size(), 1);
- m_binaryResponseBuilder->getAsBytes(
- buffer->data(), static_cast<size_t>(buffer->byteLength()));
- m_responseArrayBuffer = buffer;
+ if (buffer) {
+ m_binaryResponseBuilder->getAsBytes(
+ buffer->data(), static_cast<size_t>(buffer->byteLength()));
+ m_responseArrayBuffer = buffer;
+ }
+ // https://xhr.spec.whatwg.org/#arraybuffer-response allows clearing
+ // of the 'received bytes' payload when the response buffer allocation
+ // fails.
haraken 2017/03/03 19:23:26 I guess it would be nicer to set an exception but
sof 2017/03/03 21:23:53 https://github.com/whatwg/xhr/issues/26 has some d
m_binaryResponseBuilder.clear();
} else {
m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0);
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.cpp ('k') | third_party/WebKit/Source/wtf/typed_arrays/ArrayBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698