Commit a419b3eb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent 6019f3c1
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment