From fa62cde374ce438e471d60735a8d944f620ce795 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 4 Mar 2020 22:33:35 -0600 Subject: [PATCH] amstream: Forbid changing the graph in IAMMultiMediaStream::Initialize(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/amstream/multimedia.c | 6 ++++++ dlls/amstream/tests/amstream.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 9ca38d9fa43..e62c930a399 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -244,6 +244,12 @@ static HRESULT WINAPI multimedia_stream_Initialize(IAMMultiMediaStream *iface, TRACE("mmstream %p, type %u, flags %#x, graph %p.\n", mmstream, type, flags, graph); + if (graph && mmstream->graph) + { + WARN("Graph already initialized, returning E_INVALIDARG.\n"); + return E_INVALIDARG; + } + if (graph && FAILED(hr = create_graph(mmstream, graph))) return hr; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 3555eff9704..e2c00ebc3ae 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1646,6 +1646,15 @@ static void test_initialize(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!got_add_filter, "Got %d calls to IGraphBuilder::AddFilter().\n", got_add_filter); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_WRITE, 0, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_TRANSFORM, 0, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + IMediaStreamFilter_Release(filter); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref);