From 78f916f598b4e0acadbda2c095058bf8a268eb72 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 15 Dec 2021 11:50:19 -0600 Subject: [PATCH] winegstreamer: Return E_UNEXPECTED when calling IWMReader::Stop() if no stream is open. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52038 Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/winegstreamer/wm_asyncreader.c | 8 ++++++++ dlls/wmvcore/tests/wmvcore.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/dlls/winegstreamer/wm_asyncreader.c b/dlls/winegstreamer/wm_asyncreader.c index 18698a698e2..aa15a5a77f9 100644 --- a/dlls/winegstreamer/wm_asyncreader.c +++ b/dlls/winegstreamer/wm_asyncreader.c @@ -356,6 +356,14 @@ static HRESULT WINAPI WMReader_Stop(IWMReader *iface) TRACE("reader %p.\n", reader); EnterCriticalSection(&reader->reader.cs); + + if (!reader->reader.wg_parser) + { + LeaveCriticalSection(&reader->reader.cs); + WARN("No stream is open; returning E_UNEXPECTED.\n"); + return E_UNEXPECTED; + } + stop_streaming(reader); IWMReaderCallback_OnStatus(reader->callback, WMT_STOPPED, S_OK, WMT_TYPE_DWORD, (BYTE *)&zero, reader->context); diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index e27011f49a0..66ad89a185e 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -2169,6 +2169,9 @@ static void test_async_reader_streaming(void) IWMReader_QueryInterface(reader, &IID_IWMProfile, (void **)&profile); IWMReader_QueryInterface(reader, &IID_IWMReaderAdvanced2, (void **)&advanced); + hr = IWMReader_Stop(reader); + ok(hr == E_UNEXPECTED, "Got hr %#x.\n", hr); + hr = IWMReaderAdvanced2_OpenStream(advanced, &stream.IStream_iface, &callback.IWMReaderCallback_iface, (void **)0xdeadbeef); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount); @@ -2257,6 +2260,9 @@ static void test_async_reader_streaming(void) ok(callback.refcount == 1, "Got outstanding refcount %d.\n", callback.refcount); callback_cleanup(&callback); + hr = IWMReader_Stop(reader); + ok(hr == E_UNEXPECTED, "Got hr %#x.\n", hr); + ok(stream.refcount == 1, "Got outstanding refcount %d.\n", stream.refcount); CloseHandle(stream.file); ret = DeleteFileW(filename);