kernel32: fix memory leak (found by Smatch).

Lionel Debroux lionel_debroux at yahoo.fr
Sat Oct 6 11:39:01 CDT 2007


---
 dlls/kernel32/sync.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 08385f1..914f7f7 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -1264,14 +1264,6 @@ BOOL WINAPI WaitNamedPipeW (LPCWSTR name, DWORD nTimeOut)
         return FALSE;
     }
 
-    sz_pipe_wait = sizeof(*pipe_wait) + nt_name.Length - sizeof(leadin) - sizeof(WCHAR);
-    if (!(pipe_wait = HeapAlloc( GetProcessHeap(), 0,  sz_pipe_wait)))
-    {
-        RtlFreeUnicodeString( &nt_name );
-        SetLastError( ERROR_OUTOFMEMORY );
-        return FALSE;
-    }
-
     pipe_dev_name.Buffer = nt_name.Buffer;
     pipe_dev_name.Length = sizeof(leadin);
     pipe_dev_name.MaximumLength = sizeof(leadin);
@@ -1285,6 +1277,14 @@ BOOL WINAPI WaitNamedPipeW (LPCWSTR name, DWORD nTimeOut)
         return FALSE;
     }
 
+    sz_pipe_wait = sizeof(*pipe_wait) + nt_name.Length - sizeof(leadin) - sizeof(WCHAR);
+    if (!(pipe_wait = HeapAlloc( GetProcessHeap(), 0,  sz_pipe_wait)))
+    {
+        RtlFreeUnicodeString( &nt_name );
+        SetLastError( ERROR_OUTOFMEMORY );
+        return FALSE;
+    }
+
     pipe_wait->TimeoutSpecified = !(nTimeOut == NMPWAIT_USE_DEFAULT_WAIT);
     if (nTimeOut == NMPWAIT_WAIT_FOREVER)
         pipe_wait->Timeout.QuadPart = ((ULONGLONG)0x7fffffff << 32) | 0xffffffff;
-- 
1.5.3.1


--------------000101040209060900010805--



More information about the wine-patches mailing list