From 73f1d215e0f1fd2f80e0a50ac061c975b12bb0f3 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Thu, 10 Feb 2005 03:58:03 +0000 Subject: [PATCH] Patch to fix NtCreateSempahore, in the case where the initial lookup succeeds. We previously left the function without initializing hSemaphore. Patch suggested by me and executed by hpoussin. svn path=/trunk/; revision=13483 --- reactos/ntoskrnl/ex/sem.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/reactos/ntoskrnl/ex/sem.c b/reactos/ntoskrnl/ex/sem.c index 5a27391365c..ff75f4060da 100644 --- a/reactos/ntoskrnl/ex/sem.c +++ b/reactos/ntoskrnl/ex/sem.c @@ -128,28 +128,37 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, KeInitializeSemaphore(Semaphore, InitialCount, MaximumCount); + } - Status = ObInsertObject ((PVOID)Semaphore, + Status = ObInsertObject ((PVOID)Semaphore, NULL, DesiredAccess, 0, NULL, &hSemaphore); - ObDereferenceObject(Semaphore); - - if(NT_SUCCESS(Status)) + if(NT_SUCCESS(Status)) + { + _SEH_TRY { - _SEH_TRY - { - *SemaphoreHandle = hSemaphore; - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; + ObDereferenceObject(Semaphore); + *SemaphoreHandle = hSemaphore; } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + } else { + _SEH_TRY + { + *SemaphoreHandle = INVALID_HANDLE_VALUE; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; } return Status;