fix returning the new token handle in DuplicateTokenEx
Modified: trunk/reactos/lib/advapi32/token/token.c

Modified: trunk/reactos/lib/advapi32/token/token.c
--- trunk/reactos/lib/advapi32/token/token.c	2005-10-28 14:23:48 UTC (rev 18832)
+++ trunk/reactos/lib/advapi32/token/token.c	2005-10-28 14:31:38 UTC (rev 18833)
@@ -258,7 +258,6 @@
                   OUT PHANDLE DuplicateTokenHandle)
 {
   OBJECT_ATTRIBUTES ObjectAttributes;
-  HANDLE NewToken;
   NTSTATUS Status;
   SECURITY_QUALITY_OF_SERVICE Sqos;
 
@@ -291,7 +290,7 @@
 			     &ObjectAttributes,
 			     FALSE,
 			     TokenType,
-			     &NewToken);
+			     DuplicateTokenHandle);
   if (!NT_SUCCESS(Status))
     {
       SetLastError(RtlNtStatusToDosError(Status));
@@ -344,7 +343,7 @@
     };
     PACL Dacl;
     ULONG SidLen;
-    HANDLE hToken;
+    HANDLE hToken = NULL;
     NTSTATUS Status, AccessStatus;
 
     /* doesn't return gracefully if IsMember is NULL! */
@@ -484,7 +483,7 @@
     }
 
 Cleanup:
-    if (hToken != ExistingTokenHandle)
+    if (hToken != NULL && hToken != ExistingTokenHandle)
     {
         NtClose(hToken);
     }