fixed a memory leak in EnterCriticalPolicySection()
Modified: trunk/reactos/lib/userenv/gpolicy.c

Modified: trunk/reactos/lib/userenv/gpolicy.c
--- trunk/reactos/lib/userenv/gpolicy.c	2006-01-12 18:50:39 UTC (rev 20809)
+++ trunk/reactos/lib/userenv/gpolicy.c	2006-01-12 18:56:21 UTC (rev 20810)
@@ -477,29 +477,29 @@
 
     /* create or open the mutex */
     lpSecurityDescriptor = CreateDefaultSecurityDescriptor();
-    if (lpSecurityDescriptor == NULL)
+    if (lpSecurityDescriptor != NULL)
     {
-        return NULL;
-    }
+        SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
+        SecurityAttributes.lpSecurityDescriptor = lpSecurityDescriptor;
+        SecurityAttributes.bInheritHandle = FALSE;
 
-    SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
-    SecurityAttributes.lpSecurityDescriptor = lpSecurityDescriptor;
-    SecurityAttributes.bInheritHandle = FALSE;
+        hSection = CreateMutexW(&SecurityAttributes,
+                                FALSE,
+                                (bMachine ? szMachineGPMutex : szLocalGPMutex));
 
-    hSection = CreateMutexW(&SecurityAttributes,
-                            FALSE,
-                            (bMachine ? szMachineGPMutex : szLocalGPMutex));
+        LocalFree((HLOCAL)lpSecurityDescriptor);
 
-    if (hSection != NULL)
-    {
-        /* wait up to 10 seconds */
-        if (WaitForSingleObject(hSection,
-                                60000) != WAIT_FAILED)
+        if (hSection != NULL)
         {
-            return hSection;
+            /* wait up to 10 seconds */
+            if (WaitForSingleObject(hSection,
+                                    60000) != WAIT_FAILED)
+            {
+                return hSection;
+            }
+
+            CloseHandle(hSection);
         }
-
-        CloseHandle(hSection);
     }
 
     return NULL;