Commit 9b571645 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[canvas] Don't copy into byte array of size 0

When StaticBitmapImage::SizeInBytes returned 0,
StaticBitmapImage::CopyToByteArray did not result in a no-op as
expected. With this CL we add a check to
StaticBitmapImage::CopyToByteArray to return early if the incoming byte
array has size 0.

R=jbroman@chromium.org

Bug: chromium:1017918
Change-Id: I79952218a483735815144000185a94f313a8e968
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883627
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709921}
parent fb7068fc
......@@ -111,6 +111,9 @@ bool StaticBitmapImage::CopyToByteArray(
if (!src_image)
return true;
if (dst.size() == 0)
return true;
SkColorType color_type =
(color_params.GetSkColorType() == kRGBA_F16_SkColorType)
? kRGBA_F16_SkColorType
......
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<canvas id="canvas1" width=974px></canvas>
<script>
test(() => {
let C = document.getElementById("canvas1");
let Z = C.getContext("2d");
Z.getImageData(174.696924716, -3.94829667221, 6.80556775521, 291126556.736);
}, "Regression test for https://crbug.com/1017918.");
</script>
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