From 57fdde9558bdf95c79d0a45c4e88b1b04d168375 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Thu, 12 Jan 2006 18:56:21 +0000 Subject: [PATCH] fixed a memory leak in EnterCriticalPolicySection() svn path=/trunk/; revision=20810 --- reactos/lib/userenv/gpolicy.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/reactos/lib/userenv/gpolicy.c b/reactos/lib/userenv/gpolicy.c index 28259e85102..26cd2540d80 100644 --- a/reactos/lib/userenv/gpolicy.c +++ b/reactos/lib/userenv/gpolicy.c @@ -477,29 +477,29 @@ EnterCriticalPolicySection(IN BOOL bMachine) /* 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;