Re2: EnumMedia patch

Maarten Lankhorst m.b.lankhorst at
Sun May 1 06:04:21 CDT 2005

Robert Shearman wrote:

> Maarten Lankhorst wrote:
>> This patch fixes AM_MEDIA_TYPE->pbFormat not being handled correctly, 
>> unfortunately, this also means some stuff has to be rewritten to 
>> avoid memleaks, instead of CoTaskMemFree(AM_MEDIA_TYPE), 
>> DeleteMediaType has to be used.. This also fixes the errors i had 
>> with msn webcam, i feel like i stumbled over every bug in quartz 
>> now......
>> ------------------------------------------------------------------------
>> @@ -45,6 +46,7 @@ void DeleteMediaType(AM_MEDIA_TYPE * pMe
>>         IUnknown_Release(pMediaType->pUnk);
>>         pMediaType->pUnk = NULL;
>>     }
>> +    CoTaskMemFree(pMediaType);
>> }
>> BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const 
>> AM_MEDIA_TYPE * pmt2, BOOL bWildcards)
> This change is wrong. DeleteMediaType is not supposed to free the 
> memory used for the AM_MEDIA_TYPE structure itself as the function is 
> also used in places where the AM_MEDIA_TYPE was not allocated using 
> CoTaskMemAlloc.
> Rob
This change is right, if you don't want to release the format block you 
need to use freemediatype... quoting msdn...


The **DeleteMediaType* *function deletes an allocated *AM_MEDIA_TYPE* 
structure, including the format block.


|*void WINAPI *DeleteMediaType*(
*    *AM_MEDIA_TYPE* /*pmt/


/pmt /

Pointer to an *AM_MEDIA_TYPE* structure.

*Return Value*

No return value.


Use this function to release any media type structure that was allocated 
using either *CoTaskMemAlloc* or *CreateMediaType* 

If you prefer not to link to the base class library, you can use the 
following code directly:

|void MyDeleteMediaType(AM_MEDIA_TYPE *pmt)
    if (pmt != NULL)
        MyFreeMediaType(*pmt); // See FreeMediaType for the implementation.


*  Header:* Declared in Mtype.h; include Streams.h.

*  Library:* Use Strmbase.lib (retail builds) or Strmbasd.lib (debug 

More information about the wine-devel mailing list