[PATCH v2] ole32: Fix memory leak in CompositeMonikerImpl_Construct.

Alex Henrie alexhenrie24 at gmail.com
Tue Apr 12 23:16:21 CDT 2016


Coverity #713613, "Variable This going out of scope leaks the storage it
points to."

If we need to loop through This->tabMoniker and call IMoniker_Release on
each of its items, we should do the same in the other three similar
error paths in this function. Please let me know if this is what you
want.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/ole32/compositemoniker.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlls/ole32/compositemoniker.c b/dlls/ole32/compositemoniker.c
index e1e0e5c..6841d85 100644
--- a/dlls/ole32/compositemoniker.c
+++ b/dlls/ole32/compositemoniker.c
@@ -1848,8 +1848,11 @@ CompositeMonikerImpl_Construct(IMoniker **ppMoniker, IMoniker *pmkFirst, IMonike
             IMoniker_Release(This->tabMoniker[This->tabLastIndex-1]);
 
             This->tabMoniker[This->tabLastIndex-1]=tempMk;
-        } else
+        } else{
+            HeapFree(GetProcessHeap(), 0, This->tabMoniker);
+            HeapFree(GetProcessHeap(), 0, This);
             return res;
+        }
 
         /* resize tabMoniker if needed */
         if (This->tabLastIndex==This->tabSize){
-- 
2.8.0




More information about the wine-patches mailing list