Previously, ImmGenerateMessage could return early when ImmLockIMCC(ctx->hMsgBuf) failed, without unlocking the HIMC obtained via ImmLockIMC. This could leave the HIMC locked and lead to resource leaks.
This patch adds calls to ImmUnlockIMC(himc) at all early return points, and also unlocks the HIMC before returning TRUE at the end, ensuring that every ImmLockIMC call is properly balanced with a corresponding ImmUnlockIMC.
Tested on: Ubuntu 25.10 & deepin Linux V25, Wine compiled from master branch. No functional behavior of message dispatch is changed.
Signed-off-by: chenzhengyong chenzhengyong@uniontech.com
From: chenzhengyong chenzhengyong@uniontech.com
Signed-off-by: chenzhengyong chenzhengyong@uniontech.com --- dlls/imm32/imm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 1d5b8cd8fa3..0b2814da2cb 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -3073,13 +3073,18 @@ BOOL WINAPI ImmGenerateMessage( HIMC himc ) while (ctx->dwNumMsgBuf--) { TRANSMSG *msgs, msg; - if (!(msgs = ImmLockIMCC( ctx->hMsgBuf ))) return FALSE; + if (!(msgs = ImmLockIMCC( ctx->hMsgBuf ))) + { + ImmUnlockIMC( himc ); + return FALSE; + } msg = msgs[0]; memmove( msgs, msgs + 1, ctx->dwNumMsgBuf * sizeof(*msgs) ); ImmUnlockIMCC( ctx->hMsgBuf ); SendMessageW( ctx->hWnd, msg.message, msg.wParam, msg.lParam ); } ctx->dwNumMsgBuf++; + ImmUnlockIMC( himc );
return TRUE; }
Thanks! Fwiw you didn't need to close and open another merge request. Using `git push <remote> <branch> -f` with the branch name you used is enough to update an existing merge request with some new commits.
This merge request was approved by Rémi Bernon.