[NTUSER] Fix UserDestroyInputContext (again) (#4476)

Fix the HIMC handle leak. CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-05-03 03:43:26 +09:00 committed by GitHub
parent 14d50cc6c0
commit 4a748a3a97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -1465,10 +1465,11 @@ VOID UserFreeInputContext(PVOID Object)
BOOLEAN UserDestroyInputContext(PVOID Object) BOOLEAN UserDestroyInputContext(PVOID Object)
{ {
PIMC pIMC = Object; PIMC pIMC = Object;
if (!pIMC || !UserMarkObjectDestroy(pIMC)) if (!pIMC)
return TRUE; return TRUE;
return UserDeleteObject(UserHMGetHandle(pIMC), TYPE_INPUTCONTEXT); UserDeleteObject(UserHMGetHandle(pIMC), TYPE_INPUTCONTEXT);
return TRUE;
} }
// Win: DestroyInputContext // Win: DestroyInputContext
@ -1560,6 +1561,7 @@ PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
// Release the extra reference (UserCreateObject added 2 references). // Release the extra reference (UserCreateObject added 2 references).
UserDereferenceObject(pIMC); UserDereferenceObject(pIMC);
ASSERT(pIMC->head.cLockObj == 1);
if (dwClientImcData) // Non-first time. if (dwClientImcData) // Non-first time.
{ {
@ -1572,6 +1574,7 @@ PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
// Add the first one (default) to the list. // Add the first one (default) to the list.
UserAssignmentLock((PVOID*)&pti->spDefaultImc, pIMC); UserAssignmentLock((PVOID*)&pti->spDefaultImc, pIMC);
pIMC->pImcNext = NULL; pIMC->pImcNext = NULL;
ASSERT(pIMC->head.cLockObj == 2); // UserAssignmentUnlock'ed at ExitThreadCallback
} }
pIMC->dwClientImcData = dwClientImcData; // Set it. pIMC->dwClientImcData = dwClientImcData; // Set it.

View file

@ -582,6 +582,7 @@ UserCreateObject( PUSER_HANDLE_TABLE ht,
return Object; return Object;
} }
// Win: HMMarkObjectDestroy
BOOL BOOL
FASTCALL FASTCALL
UserMarkObjectDestroy(PVOID Object) UserMarkObjectDestroy(PVOID Object)