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

Unified Diff: third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.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/imagebitmap/ImageBitmapFactories.cpp
diff --git a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
index 422ab061da14c92860b5bb19173c086db082e433..807559deb835a1e2d162937b955a9362b39d6a29 100644
--- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
+++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
@@ -176,11 +176,14 @@ void ImageBitmapFactories::ImageBitmapLoader::rejectPromise()
void ImageBitmapFactories::ImageBitmapLoader::didFinishLoading()
{
- if (!m_loader.arrayBufferResult()) {
+ RefPtr<DOMArrayBuffer> buffer = m_loader.arrayBufferResultOrNull();
+ if (!buffer) {
rejectPromise();
return;
}
- RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arrayBufferResult()->data(), m_loader.arrayBufferResult()->byteLength());
+ // FIXME: Is there a way to transfer 'buffer' without making a copy?
Stephen White 2015/10/29 16:29:52 Log a bug for this?
Justin Novosad 2015/10/29 18:26:02 Done.
+ // The loaded data is read-only, so it should be possible to avoid copying.
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)buffer->data(), buffer->byteLength());
OwnPtr<ImageSource> source = adoptPtr(new ImageSource());
source->setData(*sharedBuffer, true);

Powered by Google App Engine
This is Rietveld 408576698