From 0831be5adcf440b6ffb8b68c75d0f65df1e7290f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 6 Mar 2008 00:32:03 -0800 Subject: [PATCH] quartz: Validate input for FilterGraph2_AddFilter. --- dlls/quartz/filtergraph.c | 3 +++ dlls/quartz/tests/filtergraph.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 5b4b7110d71..c6e2c22f6e2 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -347,6 +347,9 @@ static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface, TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName); + if (!pFilter) + return E_POINTER; + wszFilterName = CoTaskMemAlloc( (pName ? strlenW(pName) + 6 : 5) * sizeof(WCHAR) ); if (pName) diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index 758d33932df..2a2a806169a 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -148,6 +148,33 @@ static void test_graph_builder(void) releasefiltergraph(); } +static void test_graph_builder_addfilter(void) +{ + HRESULT hr; + IBaseFilter *pF = NULL; + static const WCHAR testFilterW[] = {'t','e','s','t','F','i','l','t','e','r',0}; + + if (!createfiltergraph()) + return; + + hr = IGraphBuilder_AddFilter(pgraph, NULL, testFilterW); + ok(hr == E_POINTER, "IGraphBuilder_AddFilter returned: %x\n", hr); + + /* create video filter */ + hr = CoCreateInstance(&CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, + &IID_IBaseFilter, (LPVOID*)&pF); + ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr); + ok(pF != NULL, "pF is NULL\n"); + if (!pF) { + skip("failed to created filter, skipping\n"); + return; + } + + hr = IGraphBuilder_AddFilter(pgraph, pF, NULL); + ok(hr == S_OK, "IGraphBuilder_AddFilter returned: %x\n", hr); + releasefiltergraph(); +} + static void test_filter_graph2(void) { HRESULT hr; @@ -167,5 +194,6 @@ START_TEST(filtergraph) CoInitialize(NULL); test_render_run(); test_graph_builder(); + test_graph_builder_addfilter(); test_filter_graph2(); } -- 2.11.4.GIT