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,13 +1746,15 @@ ImageData* BaseRenderingContext2D::getImageData(
}
// Read pixels into |contents|.
bool read_pixels_successful =
snapshot->PaintImageForCurrentFrame().readPixels(
image_info, contents.Data(), image_info.minRowBytes(), sx, sy);
if (!read_pixels_successful) {
SkIRect bounds =
snapshot->PaintImageForCurrentFrame().GetSkImageInfo().bounds();
DCHECK(!bounds.intersect(SkIRect::MakeXYWH(sx, sy, sw, sh)));
if (snapshot) {
const bool read_pixels_successful =
snapshot->PaintImageForCurrentFrame().readPixels(
image_info, contents.Data(), image_info.minRowBytes(), sx, sy);
if (!read_pixels_successful) {
SkIRect bounds =
snapshot->PaintImageForCurrentFrame().GetSkImageInfo().bounds();
DCHECK(!bounds.intersect(SkIRect::MakeXYWH(sx, sy, sw, sh)));
}
}
// Wrap |contents| in an ImageData.
......
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