quartz: Validate input for FilterGraph2_AddFilter.

This commit is contained in:
Lei Zhang 2008-03-06 00:32:03 -08:00 committed by Alexandre Julliard
parent 66067423d1
commit 0831be5adc
2 changed files with 31 additions and 0 deletions

View File

@ -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)

View File

@ -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();
}