kernel32: Fix possible leak of directory handle in RemoveDirectoryW.

Sebastian Lackner sebastian at fds-team.de
Mon May 2 20:22:24 CDT 2016


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
 dlls/kernel32/path.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index b3fccb2..620401d 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1655,13 +1655,19 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
     status = NtOpenFile( &handle, DELETE | SYNCHRONIZE, &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) );
+        RtlFreeUnicodeString( &nt_name );
+        return FALSE;
+    }
 
+    status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE );
+    RtlFreeUnicodeString( &nt_name );
     if (status != STATUS_SUCCESS)
     {
         SetLastError( RtlNtStatusToDosError(status) );
+        NtClose( handle );
         return FALSE;
     }
 
-- 
2.8.0



More information about the wine-patches mailing list