From 21f147630c8534be7a719b2910979de711c47e17 Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Sat, 17 Feb 2024 22:11:43 +0900 Subject: [PATCH] ntdll: Don't leak objattr allocation in NtCreateSemaphore. fsync/esync_create_semaphore allocates objattr on their own, and objattr allocated in NtCreateSemaphore was getting leaked. Like NtCreateEvent, move the objattr allocation after fsync/esync early return to avoid double allocation. --- dlls/ntdll/unix/sync.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index 62a8d9d3171..4b62f255bd5 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -273,7 +273,6 @@ NTSTATUS WINAPI NtCreateSemaphore( HANDLE *handle, ACCESS_MASK access, const OBJ *handle = 0; if (max <= 0 || initial < 0 || initial > max) return STATUS_INVALID_PARAMETER; - if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret; if (do_fsync()) return fsync_create_semaphore( handle, access, attr, initial, max ); @@ -281,6 +280,8 @@ NTSTATUS WINAPI NtCreateSemaphore( HANDLE *handle, ACCESS_MASK access, const OBJ if (do_esync()) return esync_create_semaphore( handle, access, attr, initial, max ); + if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret; + SERVER_START_REQ( create_semaphore ) { req->access = access;