Lei Zhang : quartz: Validate input for FilterGraph2_AddFilter.

Alexandre Julliard julliard at winehq.org
Thu Mar 6 11:08:35 CST 2008


Module: wine
Branch: master
Commit: 0831be5adcf440b6ffb8b68c75d0f65df1e7290f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0831be5adcf440b6ffb8b68c75d0f65df1e7290f

Author: Lei Zhang <thestig at google.com>
Date:   Thu Mar  6 00:32:03 2008 -0800

quartz: Validate input for FilterGraph2_AddFilter.

---

 dlls/quartz/filtergraph.c       |    3 +++
 dlls/quartz/tests/filtergraph.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 5b4b711..c6e2c22 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 758d339..2a2a806 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();
 }




More information about the wine-cvs mailing list