Christian Costa : strmbase: Don' t forget to add ref pUnk in CopyMediaType when pbFormat is null.

Alexandre Julliard julliard at winehq.org
Thu Nov 22 13:48:22 CST 2012


Module: wine
Branch: master
Commit: b8a7ead3a3015ee18843743997c9fbe9503cdbc9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b8a7ead3a3015ee18843743997c9fbe9503cdbc9

Author: Christian Costa <titan.costa at gmail.com>
Date:   Wed Nov 21 09:48:06 2012 +0100

strmbase: Don't forget to add ref pUnk in CopyMediaType when pbFormat is null.

---

 dlls/strmbase/mediatype.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/dlls/strmbase/mediatype.c b/dlls/strmbase/mediatype.c
index 7f19791..fef2739 100644
--- a/dlls/strmbase/mediatype.c
+++ b/dlls/strmbase/mediatype.c
@@ -28,15 +28,18 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
 
-HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc)
+HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *dest, const AM_MEDIA_TYPE *src)
 {
-    *pDest = *pSrc;
-    if (!pSrc->pbFormat) return S_OK;
-    if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
-        return E_OUTOFMEMORY;
-    memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat);
-    if (pDest->pUnk)
-        IUnknown_AddRef(pDest->pUnk);
+    *dest = *src;
+    if (src->pbFormat)
+    {
+        dest->pbFormat = CoTaskMemAlloc(src->cbFormat);
+        if (!dest->pbFormat)
+            return E_OUTOFMEMORY;
+        memcpy(dest->pbFormat, src->pbFormat, src->cbFormat);
+    }
+    if (dest->pUnk)
+        IUnknown_AddRef(dest->pUnk);
     return S_OK;
 }
 




More information about the wine-cvs mailing list