https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a748a3a97ebf153d8826…
commit 4a748a3a97ebf153d8826aa47a2dadfc3e374498
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue May 3 03:43:26 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue May 3 03:43:26 2022 +0900
[NTUSER] Fix UserDestroyInputContext (again) (#4476)
Fix the HIMC handle leak. CORE-11700
---
win32ss/user/ntuser/ime.c | 7 +++++--
win32ss/user/ntuser/object.c | 1 +
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index f8cd3778512..88c484dce82 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -1465,10 +1465,11 @@ VOID UserFreeInputContext(PVOID Object)
BOOLEAN UserDestroyInputContext(PVOID Object)
{
PIMC pIMC = Object;
- if (!pIMC || !UserMarkObjectDestroy(pIMC))
+ if (!pIMC)
return TRUE;
- return UserDeleteObject(UserHMGetHandle(pIMC), TYPE_INPUTCONTEXT);
+ UserDeleteObject(UserHMGetHandle(pIMC), TYPE_INPUTCONTEXT);
+ return TRUE;
}
// Win: DestroyInputContext
@@ -1560,6 +1561,7 @@ PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
// Release the extra reference (UserCreateObject added 2 references).
UserDereferenceObject(pIMC);
+ ASSERT(pIMC->head.cLockObj == 1);
if (dwClientImcData) // Non-first time.
{
@@ -1572,6 +1574,7 @@ PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
// Add the first one (default) to the list.
UserAssignmentLock((PVOID*)&pti->spDefaultImc, pIMC);
pIMC->pImcNext = NULL;
+ ASSERT(pIMC->head.cLockObj == 2); // UserAssignmentUnlock'ed at
ExitThreadCallback
}
pIMC->dwClientImcData = dwClientImcData; // Set it.
diff --git a/win32ss/user/ntuser/object.c b/win32ss/user/ntuser/object.c
index 492d4ab2b6b..26c407f0b56 100644
--- a/win32ss/user/ntuser/object.c
+++ b/win32ss/user/ntuser/object.c
@@ -582,6 +582,7 @@ UserCreateObject( PUSER_HANDLE_TABLE ht,
return Object;
}
+// Win: HMMarkObjectDestroy
BOOL
FASTCALL
UserMarkObjectDestroy(PVOID Object)