=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: dbghelp: Fix memory leak in SymInitializeW() (Coverity).

Alexandre Julliard julliard at winehq.org
Wed Sep 19 16:28:13 CDT 2018


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Wed Sep 19 12:26:56 2018 +0200

dbghelp: Fix memory leak in SymInitializeW() (Coverity).

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dbghelp/dbghelp.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c
index 5685c25..a085cd1 100644
--- a/dlls/dbghelp/dbghelp.c
+++ b/dlls/dbghelp/dbghelp.c
@@ -298,7 +298,8 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
 
     TRACE("(%p %s %u)\n", hProcess, debugstr_w(UserSearchPath), fInvadeProcess);
 
-    if (process_find_by_handle(hProcess)){
+    if (process_find_by_handle(hProcess))
+    {
         WARN("the symbols for this process have already been initialized!\n");
 
         /* MSDN says to only call this function once unless SymCleanup() has been called since the last call.
@@ -307,15 +308,15 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
         return TRUE;
     }
 
-    pcs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pcs));
-    if (!pcs) return FALSE;
-
-    pcs->handle = hProcess;
-
     IsWow64Process(GetCurrentProcess(), &wow64);
 
     if (!IsWow64Process(hProcess, &child_wow64))
         return FALSE;
+
+    pcs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pcs));
+    if (!pcs) return FALSE;
+
+    pcs->handle = hProcess;
     pcs->is_64bit = (sizeof(void *) == 8 || wow64) && !child_wow64;
 
     if (UserSearchPath)




More information about the wine-cvs mailing list