quartz: Fix memory leaks on error paths. Found by Smatch.

Michael Stefaniuc mstefani at redhat.de
Sun Nov 18 17:20:05 CST 2007


Though the error paths are never accessed as the *Pin_Init() functions
always return S_OK.

A nicer way would be to change the *Pin_Init() functions to return void
and thus eliminate those error paths completely. But i have no clue
about COM and thus I take the "easy" way first ...
---
 dlls/quartz/dsoundrender.c  |    4 +++-
 dlls/quartz/filesource.c    |    2 ++
 dlls/quartz/parser.c        |    8 ++++++--
 dlls/quartz/pin.c           |   12 +++++++++---
 dlls/quartz/transform.c     |    4 ++++
 dlls/quartz/videorenderer.c |    4 +++-
 6 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c
index a7ebd9f..947bb98 100644
--- a/dlls/quartz/dsoundrender.c
+++ b/dlls/quartz/dsoundrender.c
@@ -97,10 +97,12 @@ static HRESULT DSoundRender_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLE
     {
         pPinImpl->pin.lpVtbl = &DSoundRender_InputPin_Vtbl;
         pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
-        
+
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c
index 726776b..73c92b2 100644
--- a/dlls/quartz/filesource.c
+++ b/dlls/quartz/filesource.c
@@ -880,6 +880,8 @@ static HRESULT FileAsyncReader_Construct(HANDLE hFile, IBaseFilter * pBaseFilter
         *ppPin = (IPin *)(&pPinImpl->pin.pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index 39ea58b..94eb614 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -128,10 +128,12 @@ static HRESULT Parser_OutputPin_Construct(const PIN_INFO * pPinInfo, ALLOCATOR_P
     if (SUCCEEDED(Parser_OutputPin_Init(pPinInfo, props, pUserData, pQueryAccept, pmt, fSamplesPerSec, pCritSec, pPinImpl)))
     {
         pPinImpl->pin.pin.lpVtbl = &Parser_OutputPin_Vtbl;
-        
+
         *ppPin = (IPin *)pPinImpl;
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
@@ -723,10 +725,12 @@ static HRESULT Parser_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC p
     if (SUCCEEDED(PullPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
     {
         pPinImpl->pin.lpVtbl = &Parser_InputPin_Vtbl;
-        
+
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c
index 9960dff..08ddcef 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -147,10 +147,12 @@ HRESULT InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LP
     {
         pPinImpl->pin.lpVtbl = &InputPin_Vtbl;
         pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
-        
+
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
@@ -228,10 +230,12 @@ HRESULT OutputPin_Construct(const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *pro
     if (SUCCEEDED(OutputPin_Init(pPinInfo, props, pUserData, pQueryAccept, pCritSec, pPinImpl)))
     {
         pPinImpl->pin.lpVtbl = &OutputPin_Vtbl;
-        
+
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
@@ -1021,10 +1025,12 @@ HRESULT PullPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPV
     if (SUCCEEDED(PullPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
     {
         pPinImpl->pin.lpVtbl = &PullPin_Vtbl;
-        
+
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
diff --git a/dlls/quartz/transform.c b/dlls/quartz/transform.c
index b63cacd..0570a90 100644
--- a/dlls/quartz/transform.c
+++ b/dlls/quartz/transform.c
@@ -107,6 +107,8 @@ static HRESULT TransformFilter_InputPin_Construct(const PIN_INFO * pPinInfo, SAM
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
@@ -136,6 +138,8 @@ static HRESULT TransformFilter_OutputPin_Construct(const PIN_INFO * pPinInfo, co
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index 9e76fd1..67e601e 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -277,10 +277,12 @@ static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPL
     {
         pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
         pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
-      
+
         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
         return S_OK;
     }
+
+    CoTaskMemFree(pPinImpl);
     return E_FAIL;
 }
 
-- 
1.5.3.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20071119/5700221c/attachment.pgp 


More information about the wine-patches mailing list