ole32: fix memory leak in compositemoniker.c (found by Smatch).

Lionel_Debroux lionel_debroux at yahoo.fr
Sat Sep 1 10:36:57 CDT 2007


CompositeMonikerImpl_Construct leaks some heap memory in multiple error
paths. Found in Michael Stefaniuc's list of potential Wine bugs detected
by Smatch.

This patch fixes only the first memory leak. The other (potential) fixes
are less obvious.

2007-09-01  Lionel Debroux <lionel_debroux at yahoo.fr>
       * dlls/ole32/compositemoniker.c:
       ole32: fix memory leak in compositemoniker.c (found by Smatch).


-------------- next part --------------
>From e1314d6f1a14538bc867787b93c4d8cd6c3ba594 Mon Sep 17 00:00:00 2001
From: Lionel Debroux <lionel_debroux at yahoo.fr>
Date: Sat, 1 Sep 2007 16:36:11 +0200
Subject: ole32: fix memory leak in compositemoniker.c (found by Smatch).

---
 dlls/ole32/compositemoniker.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/compositemoniker.c b/dlls/ole32/compositemoniker.c
index 4a0af25..c49e9b8 100644
--- a/dlls/ole32/compositemoniker.c
+++ b/dlls/ole32/compositemoniker.c
@@ -1786,8 +1786,10 @@ CompositeMonikerImpl_Construct(IMoniker** ppMoniker,
     This->tabLastIndex=0;
 
     This->tabMoniker=HeapAlloc(GetProcessHeap(),0,This->tabSize*sizeof(IMoniker));
-    if (This->tabMoniker==NULL)
+    if (This->tabMoniker==NULL) {
+        HeapFree(GetProcessHeap(), 0, This);
         return E_OUTOFMEMORY;
+    }
 
     if (!pmkFirst && !pmkRest)
     {
-- 
1.4.4.4



More information about the wine-patches mailing list