[PATCH] mfplat/sample: Fix use-after-free of a critical section.
Nikolay Sivov
nsivov at codeweavers.com
Tue May 10 11:13:24 CDT 2022
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/mfplat/sample.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/mfplat/sample.c b/dlls/mfplat/sample.c
index ed39b5f7297..687ada1a477 100644
--- a/dlls/mfplat/sample.c
+++ b/dlls/mfplat/sample.c
@@ -183,22 +183,25 @@ static ULONG WINAPI sample_tracked_Release(IMFSample *iface)
{
struct sample *sample = impl_from_IMFSample(iface);
ULONG refcount = InterlockedDecrement(&sample->attributes.ref);
+ IRtwqAsyncResult *tracked_result = NULL;
HRESULT hr;
EnterCriticalSection(&sample->attributes.cs);
if (sample->tracked_result && sample->tracked_refcount == refcount)
{
- IRtwqAsyncResult *tracked_result = sample->tracked_result;
+ tracked_result = sample->tracked_result;
sample->tracked_result = NULL;
sample->tracked_refcount = 0;
/* Call could fail if queue system is not initialized, it's not critical. */
if (FAILED(hr = RtwqInvokeCallback(tracked_result)))
WARN("Failed to invoke tracking callback, hr %#lx.\n", hr);
- IRtwqAsyncResult_Release(tracked_result);
}
LeaveCriticalSection(&sample->attributes.cs);
+ if (tracked_result)
+ IRtwqAsyncResult_Release(tracked_result);
+
TRACE("%p, refcount %lu.\n", iface, refcount);
if (!refcount)
--
2.35.1
More information about the wine-devel
mailing list