evr/presenter: Better validate input rectangles in SetVideoPosition().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-10-05 15:26:42 +03:00 committed by Alexandre Julliard
parent 6019f3c179
commit a419b3eb79
2 changed files with 33 additions and 1 deletions

View File

@ -510,7 +510,15 @@ static HRESULT WINAPI video_presenter_control_SetVideoPosition(IMFVideoDisplayCo
return E_POINTER;
if (src_rect && (src_rect->left < 0.0f || src_rect->top < 0.0f ||
src_rect->right > 1.0f || src_rect->bottom > 1.0f))
src_rect->right > 1.0f || src_rect->bottom > 1.0f ||
src_rect->left > src_rect->right ||
src_rect->top > src_rect->bottom))
{
return E_INVALIDARG;
}
if (dst_rect && (dst_rect->left > dst_rect->right ||
dst_rect->top > dst_rect->bottom))
return E_INVALIDARG;
EnterCriticalSection(&presenter->cs);

View File

@ -1111,6 +1111,21 @@ static void test_default_presenter(void)
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
/* Flipped source rectangle. */
src_rect.left = 0.5f;
src_rect.top = 0.0f;
src_rect.right = 0.4f;
src_rect.bottom = 1.0f;
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
src_rect.left = 0.0f;
src_rect.top = 0.5f;
src_rect.right = 0.4f;
src_rect.bottom = 0.1f;
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
src_rect.left = 0.1f;
src_rect.top = 0.2f;
src_rect.right = 0.8f;
@ -1123,6 +1138,15 @@ static void test_default_presenter(void)
ok(src_rect.left == 0.1f && src_rect.top == 0.2f && src_rect.right == 0.8f &&
src_rect.bottom == 0.9f, "Unexpected source rectangle.\n");
/* Flipped destination rectangle. */
SetRect(&dst_rect, 100, 1, 50, 1000);
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
SetRect(&dst_rect, 1, 100, 100, 50);
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
SetRect(&dst_rect, 1, 2, 999, 1000);
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);