From: "Erich E. Hoover" Subject: [PATCH 11/11] kernel32: Fix leaking directory handle in RemoveDirectoryW. Message-Id: Date: Mon, 8 Sep 2014 13:52:20 -0600 This patch (by Sebastian Lackner) fixes a directory handle leak in RemoveDirectoryW he noticed while reviewing patch 9. From db36c0548d00ce0ba16a30e563e675791f4dadf9 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 28 Aug 2014 05:36:01 +0200 Subject: kernel32: Fix leaking directory handle in RemoveDirectoryW. --- dlls/kernel32/path.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index 4a41ab8..593cc1d 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1602,7 +1602,6 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path ) SetLastError( ERROR_PATH_NOT_FOUND ); return FALSE; } - unix_name.Buffer = NULL; attr.Length = sizeof(attr); attr.RootDirectory = 0; attr.Attributes = OBJ_CASE_INSENSITIVE; @@ -1613,18 +1612,21 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path ) status = NtOpenFile( &handle, DELETE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ); - if (status == STATUS_SUCCESS) - status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE ); - RtlFreeUnicodeString( &nt_name ); - if (status != STATUS_SUCCESS) { SetLastError( RtlNtStatusToDosError(status) ); - RtlFreeAnsiString( &unix_name ); + RtlFreeUnicodeString( &nt_name ); return FALSE; } - if (!(ret = (rmdir( unix_name.Buffer ) != -1))) FILE_SetDosError(); + status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE ); + RtlFreeUnicodeString( &nt_name ); + + if (status != STATUS_SUCCESS) + SetLastError( RtlNtStatusToDosError(status) ); + else if (!(ret = (rmdir( unix_name.Buffer ) != -1))) + FILE_SetDosError(); + RtlFreeAnsiString( &unix_name ); NtClose( handle ); return ret; -- 1.7.9.5