Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Upstream Commit: windowscodecs: BitmapScaler_CopyPixels: Do not demand a larger buffer than necessary. #156

Open
wants to merge 1 commit into
base: lutris-7.2-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dlls/windowscodecs/scaler.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static HRESULT WINAPI BitmapScaler_CopyPixels(IWICBitmapScaler *iface,
goto end;
}

if ((cbStride * dest_rect.Height) > cbBufferSize)
if (cbStride * (dest_rect.Height - 1) + bytesperrow > cbBufferSize)
{
hr = E_INVALIDARG;
goto end;
Expand Down
13 changes: 8 additions & 5 deletions dlls/windowscodecs/tests/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ static void test_bitmap_scaler(void)
double res_x, res_y;
IWICBitmap *bitmap;
UINT width, height;
BYTE buf[16];
BYTE buf[93];
HRESULT hr;

hr = IWICImagingFactory_CreateBitmap(factory, 4, 2, &GUID_WICPixelFormat24bppBGR, WICBitmapCacheOnLoad, &bitmap);
Expand Down Expand Up @@ -1243,28 +1243,28 @@ static void test_bitmap_scaler(void)
WICBitmapInterpolationModeNearestNeighbor);
ok(hr == E_INVALIDARG, "Failed to initialize bitmap scaler, hr %#x.\n", hr);

hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 4,
hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 7, 4,
WICBitmapInterpolationModeNearestNeighbor);
ok(hr == S_OK, "Failed to initialize bitmap scaler, hr %#x.\n", hr);

hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 4,
WICBitmapInterpolationModeNearestNeighbor);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);

hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 0,
hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 7, 0,
WICBitmapInterpolationModeNearestNeighbor);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);

hr = IWICBitmapScaler_Initialize(scaler, NULL, 8, 4, WICBitmapInterpolationModeNearestNeighbor);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);

hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 4,
hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 7, 4,
WICBitmapInterpolationModeNearestNeighbor);
ok(hr == WINCODEC_ERR_WRONGSTATE, "Unexpected hr %#x.\n", hr);

hr = IWICBitmapScaler_GetSize(scaler, &width, &height);
ok(hr == S_OK, "Failed to get scaler size, hr %#x.\n", hr);
ok(width == 8, "Unexpected width %u.\n", width);
ok(width == 7, "Unexpected width %u.\n", width);
ok(height == 4, "Unexpected height %u.\n", height);

hr = IWICBitmapScaler_GetSize(scaler, NULL, &height);
Expand Down Expand Up @@ -1307,6 +1307,9 @@ static void test_bitmap_scaler(void)
ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#x.\n", hr);
IWICPalette_Release(palette);

hr = IWICBitmapScaler_CopyPixels(scaler, NULL, /*cbStride=*/24, sizeof(buf), buf);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);

IWICBitmapScaler_Release(scaler);

IWICBitmap_Release(bitmap);
Expand Down