Akihiro Sagawa : strmbase: Add validation checks when updating destination rectangle.
Alexandre Julliard
julliard at winehq.org
Mon Nov 28 15:52:47 CST 2016
Module: wine
Branch: master
Commit: 40a596fa86f11fc2cf0d7481254692e07571418a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=40a596fa86f11fc2cf0d7481254692e07571418a
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Fri Nov 25 01:10:07 2016 +0900
strmbase: Add validation checks when updating destination rectangle.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/quartz/tests/filtergraph.c | 2 +-
dlls/strmbase/video.c | 74 +++++++++++++++++++++++++++++------------
2 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index 1b72008..3077b38 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -172,7 +172,7 @@ static void test_basic_video(void)
todo_wine ok(height == video_height, "expected %d, got %d\n", video_height, height);
hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, 0, 0);
- todo_wine ok(hr==E_INVALIDARG, "IBasicVideo_SetDestinationPosition returned: %x\n", hr);
+ ok(hr==E_INVALIDARG, "IBasicVideo_SetDestinationPosition returned: %x\n", hr);
hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, video_width*2, video_height*2);
ok(hr==S_OK, "Cannot put destination position returned: %x\n", hr);
diff --git a/dlls/strmbase/video.c b/dlls/strmbase/video.c
index 3f4d207..0f05d63 100644
--- a/dlls/strmbase/video.c
+++ b/dlls/strmbase/video.c
@@ -72,6 +72,14 @@ static HRESULT BaseControlVideoImpl_CheckSourceRect(BaseControlVideo *This, RECT
return S_OK;
}
+static HRESULT BaseControlVideoImpl_CheckTargetRect(BaseControlVideo *This, RECT *pTargetRect)
+{
+ if (IsRectEmpty(pTargetRect))
+ return E_INVALIDARG;
+
+ return S_OK;
+}
+
HRESULT WINAPI BaseControlVideoImpl_GetTypeInfoCount(IBasicVideo *iface, UINT *pctinfo)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
@@ -329,14 +337,20 @@ HRESULT WINAPI BaseControlVideoImpl_put_DestinationLeft(IBasicVideo *iface, LONG
{
RECT DestRect;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
+ HRESULT hr;
TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
- This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
- DestRect.right = (DestRect.right - DestRect.left) + DestinationLeft;
- DestRect.left = DestinationLeft;
- This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
+ hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
+ if (SUCCEEDED(hr))
+ {
+ DestRect.right = (DestRect.right - DestRect.left) + DestinationLeft;
+ DestRect.left = DestinationLeft;
+ hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
+ }
+ if (SUCCEEDED(hr))
+ hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
- return S_OK;
+ return hr;
}
HRESULT WINAPI BaseControlVideoImpl_get_DestinationLeft(IBasicVideo *iface, LONG *pDestinationLeft)
@@ -357,13 +371,19 @@ HRESULT WINAPI BaseControlVideoImpl_put_DestinationWidth(IBasicVideo *iface, LON
{
RECT DestRect;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
+ HRESULT hr;
TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
- This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
- DestRect.right = DestRect.left + DestinationWidth;
- This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
+ hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
+ if (SUCCEEDED(hr))
+ {
+ DestRect.right = DestRect.left + DestinationWidth;
+ hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
+ }
+ if (SUCCEEDED(hr))
+ hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
- return S_OK;
+ return hr;
}
HRESULT WINAPI BaseControlVideoImpl_get_DestinationWidth(IBasicVideo *iface, LONG *pDestinationWidth)
@@ -384,14 +404,20 @@ HRESULT WINAPI BaseControlVideoImpl_put_DestinationTop(IBasicVideo *iface, LONG
{
RECT DestRect;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
+ HRESULT hr;
TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
- This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
- DestRect.bottom = (DestRect.bottom - DestRect.top) + DestinationTop;
- DestRect.top = DestinationTop;
- This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
+ hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
+ if (SUCCEEDED(hr))
+ {
+ DestRect.bottom = (DestRect.bottom - DestRect.top) + DestinationTop;
+ DestRect.top = DestinationTop;
+ hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
+ }
+ if (SUCCEEDED(hr))
+ hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
- return S_OK;
+ return hr;
}
HRESULT WINAPI BaseControlVideoImpl_get_DestinationTop(IBasicVideo *iface, LONG *pDestinationTop)
@@ -412,13 +438,19 @@ HRESULT WINAPI BaseControlVideoImpl_put_DestinationHeight(IBasicVideo *iface, LO
{
RECT DestRect;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
+ HRESULT hr;
TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
- This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
- DestRect.bottom = DestRect.top + DestinationHeight;
- This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
+ hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
+ if (SUCCEEDED(hr))
+ {
+ DestRect.bottom = DestRect.top + DestinationHeight;
+ hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
+ }
+ if (SUCCEEDED(hr))
+ hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
- return S_OK;
+ return hr;
}
HRESULT WINAPI BaseControlVideoImpl_get_DestinationHeight(IBasicVideo *iface, LONG *pDestinationHeight)
@@ -482,9 +514,9 @@ HRESULT WINAPI BaseControlVideoImpl_SetDestinationPosition(IBasicVideo *iface, L
TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
SetRect(&DestRect, Left, Top, Left + Width, Top + Height);
- This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
-
- return S_OK;
+ if (FAILED(BaseControlVideoImpl_CheckTargetRect(This, &DestRect)))
+ return E_INVALIDARG;
+ return This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
}
HRESULT WINAPI BaseControlVideoImpl_GetDestinationPosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
More information about the wine-cvs
mailing list