Is there anything wrong with this patch ? I think this one is a real memory leak.
"WaitNamedPipeW" in dlls/kernel32/sync.c gets flagged by Michael Stefaniuc's unfree-wine.pl script for leaking "pipe_wait". pipe_wait isn't used anywhere between its allocation and the memory leak in the error path. nt_name.Length, which is used for computing sz_pipe_wait isn't modified either in those lines. Therefore, I fixed the leak in the error path by moving the allocation later in the program. 2007-10-06 Lionel Debroux <[EMAIL PROTECTED]> * dlls/kernel32/sync.c: kernel32: fix memory leak (found by Smatch). _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
>From bd29284fa4edb04f266bb466f571831959c59c97 Mon Sep 17 00:00:00 2001 From: Lionel Debroux <[EMAIL PROTECTED]> Date: Sat, 6 Oct 2007 18:39:01 +0200 Subject: kernel32: fix memory leak (found by Smatch). --- 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