PATCH: ntdll: fixed leaking unix_name in RemoveDirectoryW

Marcus Meissner marcus at jet.franken.de
Thu Jun 11 04:28:20 CDT 2015


>From fbb6ccb252d14593cefa5e47a5a6566406f79c40 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian at fds-team.de>
Date: Thu, 28 Aug 2014 05:36:01 +0200
Subject: kernel32: Fix leaking directory handle in RemoveDirectoryW. (try 2)

---
 dlls/kernel32/path.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 09fb04b..7e20dc3 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1612,18 +1612,23 @@ 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) );
+        RtlFreeUnicodeString( &nt_name );
         return FALSE;
     }
 
-    if (!(ret = (rmdir( unix_name.Buffer ) != -1))) FILE_SetDosError();
-    RtlFreeAnsiString( &unix_name );
+    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();
+
+    if (status == STATUS_SUCCESS)
+        RtlFreeAnsiString( &unix_name );
     NtClose( handle );
     return ret;
 }
-- 
1.7.9.5




More information about the wine-patches mailing list