Uninitialized variable in DIBPixelData can cause a dangerous memory write
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2016 12:38:37 +0000 (12:38 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2016 12:38:37 +0000 (12:38 +0000)
commit4da663439850ce87e61a2fb40ddd25ffcc5b0a12
tree974566c2be2afa7d4d7176a4697dabc8536ac2af
parent164111fb8adf7c05356c30540232553015a4c8f9
Uninitialized variable in DIBPixelData can cause a dangerous memory write
https://bugs.webkit.org/show_bug.cgi?id=159414

Reviewed by Brent Fulgham.

Source/WebCore:

Initialize local BITMAP variable, in case the ::GetObject function that should initialize it
fails to do so, because the bitmap handle is invalid.

Tests: Tools/TestWebKitAPI/Tests/WebCore/win/DIBPixelData.cpp

* platform/graphics/win/DIBPixelData.cpp:
(WebCore::DIBPixelData::initialize): Initialize local variable.
(WebCore::DIBPixelData::setRGBABitmapAlpha): Return early if we have no bitmap.
* platform/graphics/win/DIBPixelData.h: Link fix.

Tools:

Add test to check that DIBPixelData::setRGBABitmapAlpha does not cause a crash
when the HDC parameter is invalid.

* TestWebKitAPI/PlatformWin.cmake:
* TestWebKitAPI/Tests/WebCore/win/DIBPixelData.cpp: Added.
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/win/DIBPixelData.cpp
Source/WebCore/platform/graphics/win/DIBPixelData.h
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformWin.cmake
Tools/TestWebKitAPI/Tests/WebCore/win/DIBPixelData.cpp [new file with mode: 0644]