Commit 413a7a7c authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Canvas: fix crash in BaseRenderingContext2D::getImageData

The code prior to this patch did not fail if GetImage returns nullptr.

Bug: 1149954
Change-Id: If87d16ea2573cc8e5db1e419b743d37bc5062ceb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545035Reviewed-by: default avatarYi Xu <yiyix@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828940}
parent c1895d6c
...@@ -1746,7 +1746,8 @@ ImageData* BaseRenderingContext2D::getImageData( ...@@ -1746,7 +1746,8 @@ ImageData* BaseRenderingContext2D::getImageData(
} }
// Read pixels into |contents|. // Read pixels into |contents|.
bool read_pixels_successful = if (snapshot) {
const bool read_pixels_successful =
snapshot->PaintImageForCurrentFrame().readPixels( snapshot->PaintImageForCurrentFrame().readPixels(
image_info, contents.Data(), image_info.minRowBytes(), sx, sy); image_info, contents.Data(), image_info.minRowBytes(), sx, sy);
if (!read_pixels_successful) { if (!read_pixels_successful) {
...@@ -1754,6 +1755,7 @@ ImageData* BaseRenderingContext2D::getImageData( ...@@ -1754,6 +1755,7 @@ ImageData* BaseRenderingContext2D::getImageData(
snapshot->PaintImageForCurrentFrame().GetSkImageInfo().bounds(); snapshot->PaintImageForCurrentFrame().GetSkImageInfo().bounds();
DCHECK(!bounds.intersect(SkIRect::MakeXYWH(sx, sy, sw, sh))); DCHECK(!bounds.intersect(SkIRect::MakeXYWH(sx, sy, sw, sh)));
} }
}
// Wrap |contents| in an ImageData. // Wrap |contents| in an ImageData.
DOMArrayBuffer* array_buffer = DOMArrayBuffer::Create(std::move(contents)); DOMArrayBuffer* array_buffer = DOMArrayBuffer::Create(std::move(contents));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment