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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.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/platform/graphics/ImageBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
index 06088dc9d96fd00d3197d204eef963a114bd624c..643c769c2dbd32eeace3838d06fafc46d10ab3f1 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -54,6 +54,7 @@
#include "third_party/skia/include/core/SkPicture.h"
#include "wtf/ArrayBufferContents.h"
#include "wtf/MathExtras.h"
+#include "wtf/PartitionAlloc.h"
#include "wtf/Vector.h"
#include "wtf/text/Base64.h"
#include "wtf/text/WTFString.h"
@@ -290,7 +291,9 @@ bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::Ar
return false;
if (!isSurfaceValid()) {
- WTF::ArrayBufferContents result(rect.width() * rect.height(), 4, WTF::ArrayBufferContents::NotShared, WTF::ArrayBufferContents::ZeroInitialize);
+ WTF::ArrayBufferContents result(rect.width() * rect.height(), 4, WTF::ArrayBufferContents::NotShared, WTF::ArrayBufferContents::ZeroInitialize, WTF::ArrayBufferContents::NullDataIfOutOfMemory);
+ if (!result.data())
+ return false;
result.transfer(contents);
return true;
}
@@ -311,7 +314,11 @@ bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::Ar
WTF::ArrayBufferContents::NotShared,
mayHaveStrayArea
? WTF::ArrayBufferContents::ZeroInitialize
- : WTF::ArrayBufferContents::DontInitialize);
+ : WTF::ArrayBufferContents::DontInitialize,
+ WTF::ArrayBufferContents::NullDataIfOutOfMemory);
+
+ if (!result.data())
+ return false;
SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), kRGBA_8888_SkColorType, alphaType);

Powered by Google App Engine
This is Rietveld 408576698