[NTUSER] Plan A: UserDereferenceObject in UserCreateInputContext (#4247)

- Call UserDereferenceObject function in UserCreateInputContext.
- Don't call UserDereferenceObject against input context at the other places.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-01-05 08:15:32 +09:00 committed by GitHub
parent 1f6cd38050
commit 8e8f61989a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -654,11 +654,7 @@ InitThreadCallback(PETHREAD Thread)
/* Create the default input context */
if (IS_IMM_MODE())
{
PIMC pIMC = UserCreateInputContext(0);
if (pIMC)
{
UserDereferenceObject(pIMC);
}
(VOID)UserCreateInputContext(0);
}
/* Last things to do only if we are not a SYSTEM or CSRSS thread */

View file

@ -482,6 +482,9 @@ PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
if (!pIMC)
return NULL;
// Release the extra reference (UserCreateObject added 2 references).
UserDereferenceObject(pIMC);
if (dwClientImcData) // Non-first time.
{
// Insert pIMC to the second position (non-default) of the list.
@ -506,17 +509,17 @@ NtUserCreateInputContext(ULONG_PTR dwClientImcData)
PIMC pIMC;
HIMC ret = NULL;
if (!dwClientImcData)
return NULL;
UserEnterExclusive();
if (!IS_IMM_MODE() || !dwClientImcData)
if (!IS_IMM_MODE())
goto Quit;
pIMC = UserCreateInputContext(dwClientImcData);
if (pIMC)
{
ret = UserHMGetHandle(pIMC);
UserDereferenceObject(pIMC);
}
Quit:
UserLeave();