Module: wine Branch: master Commit: af089289b32dbeec797f810938bca4adc8f717db URL: http://source.winehq.org/git/wine.git/?a=commit;h=af089289b32dbeec797f810938...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Fri May 2 22:14:24 2014 +0900
msvfw32: Fix uncompressed bitmap size handling in DrawDibDraw.
---
dlls/msvfw32/drawdib.c | 8 ++------ dlls/msvfw32/tests/drawdib.c | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/msvfw32/drawdib.c b/dlls/msvfw32/drawdib.c index 2916126..c4e5c40 100644 --- a/dlls/msvfw32/drawdib.c +++ b/dlls/msvfw32/drawdib.c @@ -355,12 +355,6 @@ BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc,
if (!(wFlags & DDF_UPDATE)) { - DWORD biSizeImage = lpbi->biSizeImage; - - /* biSizeImage may be set to 0 for BI_RGB (uncompressed) bitmaps */ - if ((lpbi->biCompression == BI_RGB) && (biSizeImage == 0)) - biSizeImage = ((lpbi->biWidth * lpbi->biBitCount + 31) / 32) * 4 * lpbi->biHeight; - if (lpbi->biCompression) { DWORD flags = 0; @@ -374,6 +368,8 @@ BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc, } else { + /* BI_RGB: lpbi->biSizeImage isn't reliable */ + DWORD biSizeImage = ((lpbi->biWidth * lpbi->biBitCount + 31) / 32) * 4 * lpbi->biHeight; memcpy(whdd->lpvbits, lpBits, biSizeImage); } } diff --git a/dlls/msvfw32/tests/drawdib.c b/dlls/msvfw32/tests/drawdib.c index 24d8631..0a59d82 100644 --- a/dlls/msvfw32/tests/drawdib.c +++ b/dlls/msvfw32/tests/drawdib.c @@ -105,6 +105,12 @@ static void test_DrawDib_sizeimage(void) { 0, 0, 0, "" }, { 0, HEIGHT, 0, "" }, { WIDTH, 0, 0, "" }, + /* [8] zero size (to compare [9], [10] ) */ + { WIDTH, HEIGHT/2, 0, "8b75bf6d54a8645380114fe77505ee0699ffffaa" }, + /* [9] insufficient size */ + { WIDTH, HEIGHT/2, sizeof(RGBQUAD), "8b75bf6d54a8645380114fe77505ee0699ffffaa" }, + /* [10] too much size */ + { WIDTH, HEIGHT/2, WIDTH * HEIGHT * sizeof(RGBQUAD), "8b75bf6d54a8645380114fe77505ee0699ffffaa" }, }; HDC hdc; DWORD src_dib_size, dst_dib_size;