Out of bounds write in canvas.toDataURL
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jan 2015 05:14:56 +0000 (05:14 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jan 2015 05:14:56 +0000 (05:14 +0000)
commit8957004f00f098aa5484f5f64ab45b3ca4a4b603
tree4336c16935c6a0911621464d41dae0670bfa6057
parent27e3fc2c8fb4795f0d45e42590ee550432d32e84
Out of bounds write in canvas.toDataURL
https://bugs.webkit.org/show_bug.cgi?id=140594
<rdar://problem/19449135>

Reviewed by Alexey Proskuryakov.

Source/WebCore:

In the case where we have a canvas object that does
not have premultiplied alpha (an option you can select
when using WebGL) we have to multiply out the alpha when
converting to JPEG via toDataURL.

For this we created a buffer, but were not accurately
resizing it before flattening the alpha.

Test: fast/canvas/webgl/toDataURL-unpremultipliedAlpha.html

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageDataToDataURL): Call resize once we've
determined we have enough space.

LayoutTests:

Creates a WebGL context that does not have
premultiplied alpha, fills it with 50% transparent white,
and attempts to convert the canvas to a JPEG data URL. This
exercises the code path that was not accurately
allocating data (to flatten the alpha).

* fast/canvas/webgl/toDataURL-unpremultipliedAlpha-expected.txt: Added.
* fast/canvas/webgl/toDataURL-unpremultipliedAlpha.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/toDataURL-unpremultipliedAlpha-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/toDataURL-unpremultipliedAlpha.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp