strmbase: Avoid leaking the media type on failure in IEnumMediaTypes::Next().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-06-06 16:22:44 -05:00 committed by Alexandre Julliard
parent 2cf4b6016e
commit 07729ea4ef
1 changed files with 9 additions and 4 deletions

View File

@ -119,6 +119,7 @@ static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count,
AM_MEDIA_TYPE **mts, ULONG *ret_count)
{
struct enum_media_types *enummt = impl_from_IEnumMediaTypes(iface);
AM_MEDIA_TYPE mt;
unsigned int i;
HRESULT hr;
@ -133,10 +134,14 @@ static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count,
for (i = 0; i < count; ++i)
{
if ((mts[i] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
hr = enummt->pin->ops->pin_get_media_type(enummt->pin, enummt->index + i, mts[i]);
else
hr = E_OUTOFMEMORY;
hr = enummt->pin->ops->pin_get_media_type(enummt->pin, enummt->index + i, &mt);
if (hr == S_OK)
{
if ((mts[i] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
*mts[i] = mt;
else
hr = E_OUTOFMEMORY;
}
if (FAILED(hr))
{
while (i--)