mf: Fix timer instance leak on error path in SetTimer().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-05-06 15:49:11 +03:00 committed by Alexandre Julliard
parent 1f90b33daf
commit 35242aa417
1 changed files with 9 additions and 5 deletions

View File

@ -4093,15 +4093,19 @@ static HRESULT WINAPI present_clock_timer_SetTimer(IMFTimer *iface, DWORD flags,
hr = MF_S_CLOCK_STOPPED;
if (SUCCEEDED(hr))
{
list_add_tail(&clock->timers, &clock_timer->entry);
if (cancel_key)
{
*cancel_key = &clock_timer->IUnknown_iface;
IUnknown_AddRef(*cancel_key);
}
}
LeaveCriticalSection(&clock->cs);
if (SUCCEEDED(hr) && cancel_key)
{
*cancel_key = &clock_timer->IUnknown_iface;
IUnknown_AddRef(*cancel_key);
}
if (FAILED(hr))
IUnknown_Release(&clock_timer->IUnknown_iface);
return hr;
}