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

Unified Diff: Source/modules/imagebitmap/ImageBitmapFactories.cpp

Issue 211313003: Fix crash when creating an ImageBitmap from an invalid canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: staticity reinstalment Created 6 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
« no previous file with comments | « LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/imagebitmap/ImageBitmapFactories.cpp
diff --git a/Source/modules/imagebitmap/ImageBitmapFactories.cpp b/Source/modules/imagebitmap/ImageBitmapFactories.cpp
index fd4eaf0625fb6ac3dfd00303b406e94198713931..fb6723d7312834a5af4ec218135d874e23ec111d 100644
--- a/Source/modules/imagebitmap/ImageBitmapFactories.cpp
+++ b/Source/modules/imagebitmap/ImageBitmapFactories.cpp
@@ -67,7 +67,12 @@ static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtrWil
{
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(context);
ScriptPromise promise = resolver->promise();
- resolver->resolve(imageBitmap);
+ if (imageBitmap) {
+ resolver->resolve(imageBitmap);
+ } else {
+ v8::Isolate* isolate = ScriptState::current()->isolate();
+ resolver->reject(ScriptValue(v8::Null(isolate), isolate));
+ }
return promise;
}
@@ -185,8 +190,9 @@ ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget,
exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width"));
return ScriptPromise();
}
+
// FIXME: make ImageBitmap creation asynchronous crbug.com/258082
- return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::create(canvas, IntRect(sx, sy, sw, sh)));
+ return fulfillImageBitmap(eventTarget.executionContext(), canvas->buffer() ? ImageBitmap::create(canvas, IntRect(sx, sy, sw, sh)) : nullptr);
}
ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, Blob* blob, ExceptionState& exceptionState)
« no previous file with comments | « LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698