Commit 51021faa authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

strmbase: Fix media type leaks when creating IEnumMediaTypes instance (Valgrind).

parent 5f38bfed
......@@ -125,18 +125,23 @@ HRESULT WINAPI EnumMediaTypes_Construct(BasePin *basePin, BasePin_GetMediaType e
pEnumMediaTypes->basePin = basePin;
i = 0;
while (enumFunc(basePin, i, &amt) == S_OK) i++;
while (enumFunc(basePin, i, &amt) == S_OK)
{
FreeMediaType(&amt);
i++;
}
pEnumMediaTypes->enumMediaDetails.cMediaTypes = i;
pEnumMediaTypes->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * i);
memset(pEnumMediaTypes->enumMediaDetails.pMediaTypes, 0, sizeof(AM_MEDIA_TYPE) * i);
for (i = 0; i < pEnumMediaTypes->enumMediaDetails.cMediaTypes; i++)
{
enumFunc(basePin,i,&amt);
if (FAILED(CopyMediaType(&pEnumMediaTypes->enumMediaDetails.pMediaTypes[i], &amt)))
HRESULT hr;
if (FAILED(hr = enumFunc(basePin, i, &pEnumMediaTypes->enumMediaDetails.pMediaTypes[i])))
{
IEnumMediaTypes_Release(&pEnumMediaTypes->IEnumMediaTypes_iface);
return E_OUTOFMEMORY;
return hr;
}
}
*ppEnum = &pEnumMediaTypes->IEnumMediaTypes_iface;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment