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

Unified Diff: third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverting some behavior changes 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/fileapi/FileReaderSync.cpp
diff --git a/third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp b/third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp
index b2b8004c030b0422539343b98879f1aa38003944..def482d719656a40f7f486b6cef08e0a80429f00 100644
--- a/third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp
+++ b/third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp
@@ -55,7 +55,14 @@ PassRefPtr<DOMArrayBuffer> FileReaderSync::readAsArrayBuffer(ExecutionContext* e
FileReaderLoader loader(FileReaderLoader::ReadAsArrayBuffer, nullptr);
startLoading(executionContext, loader, *blob, exceptionState);
- return loader.arrayBufferResult();
+ RefPtr<DOMArrayBuffer> result = loader.arrayBufferResultOrNull();
+ // FIXME(crbug.com/536816): Instead of crashing on OOM here, we should
+ // probably throw a RangeError exception which is what the ECMAScript
+ // spec says to do when allocation fails. However, the File API spec
+ // would need to be modified to state that execption thrown by referenced
+ // procedures are re-thrown.
+ RELEASE_ASSERT(result); // This is essentially an OOM crash
+ return result.release();
}
String FileReaderSync::readAsBinaryString(ExecutionContext* executionContext, Blob* blob, ExceptionState& exceptionState)

Powered by Google App Engine
This is Rietveld 408576698