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

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

Issue 2730943002: XMLHttpRequest: return null upon failing responseArrayBuffer allocation. (Closed)
Patch Set: update comment Created 3 years, 9 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 c74d9e94739cd731464822eaaff8b2fe52b1bfc5..141603d573116da0d95b87eab645a61c3e758aab 100644
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -388,11 +388,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.
m_binaryResponseBuilder.clear();
} else {
m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0);
yhirano 2017/03/06 09:19:53 This getter returns null for the first time, and w
sof 2017/03/06 09:29:16 Hmm, yes. It implements the spec by doing so, I'd
« 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