From 710cc2bcfb9d9e5a39de3612edcf4ef7ca4739b0 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 15 May 2020 18:32:55 +0300 Subject: [PATCH] mf/samplegrabber: Test shutdown state under the lock for methods that modify item queue. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mf/samplegrabber.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/mf/samplegrabber.c b/dlls/mf/samplegrabber.c index 24d9163d195..92330abc9fe 100644 --- a/dlls/mf/samplegrabber.c +++ b/dlls/mf/samplegrabber.c @@ -407,12 +407,11 @@ static HRESULT WINAPI sample_grabber_stream_ProcessSample(IMFStreamSink *iface, if (!sample) return S_OK; - if (grabber->is_shut_down) - return MF_E_STREAMSINK_REMOVED; - EnterCriticalSection(&grabber->cs); - if (grabber->state == SINK_STATE_RUNNING) + if (grabber->is_shut_down) + hr = MF_E_STREAMSINK_REMOVED; + else if (grabber->state == SINK_STATE_RUNNING) { hr = IMFSample_GetSampleTime(sample, &sampletime); @@ -479,12 +478,11 @@ static HRESULT WINAPI sample_grabber_stream_PlaceMarker(IMFStreamSink *iface, MF TRACE("%p, %d, %p, %p.\n", iface, marker_type, marker_value, context_value); - if (grabber->is_shut_down) - return MF_E_STREAMSINK_REMOVED; - EnterCriticalSection(&grabber->cs); - if (grabber->state == SINK_STATE_RUNNING) + if (grabber->is_shut_down) + hr = MF_E_STREAMSINK_REMOVED; + else if (grabber->state == SINK_STATE_RUNNING) hr = stream_place_marker(grabber, marker_type, context_value); LeaveCriticalSection(&grabber->cs);