Module: wine Branch: master Commit: fd67f32ee38d5d3fc49f301f22a60f9cfce41db9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=fd67f32ee38d5d3fc49f301f22...
Author: Aric Stewart aric@codeweavers.com Date: Fri Feb 15 13:22:28 2008 -0600
imm: Ensure hCompStr handle is not NULL and check for empty composition strings properly.
---
dlls/imm32/imm.c | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 78c61ce..6b4e288 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -194,6 +194,18 @@ static LRESULT ImmInternalSendIMENotify(WPARAM notify, LPARAM lParam) return 0; }
+static HIMCC ImmCreateBlankCompStr(void) +{ + HIMCC rc; + LPCOMPOSITIONSTRING ptr; + rc = ImmCreateIMCC(sizeof(COMPOSITIONSTRING)); + ptr = (LPCOMPOSITIONSTRING)ImmLockIMCC(rc); + memset(ptr,0,sizeof(COMPOSITIONSTRING)); + ptr->dwSize = sizeof(COMPOSITIONSTRING); + ImmUnlockIMCC(rc); + return rc; +} + static void ImmInternalSetOpenStatus(BOOL fOpen) { TRACE("Setting internal state to %s\n",(fOpen)?"OPEN":"CLOSED"); @@ -202,7 +214,7 @@ static void ImmInternalSetOpenStatus(BOOL fOpen) { ShowWindow(hwndDefault,SW_HIDE); ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = NULL; + root_context->IMC.hCompStr = ImmCreateBlankCompStr(); }
root_context->IMC.fOpen = fOpen; @@ -597,6 +609,9 @@ HIMC WINAPI ImmCreateContext(void)
new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData));
+ /* hCompStr is never NULL */ + new_context->IMC.hCompStr = ImmCreateBlankCompStr(); + return (HIMC)new_context; }
@@ -1411,14 +1426,17 @@ BOOL WINAPI ImmNotifyIME( TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL"); { BOOL send; + LPCOMPOSITIONSTRING lpCompStr;
if (pX11DRV_ForceXIMReset) pX11DRV_ForceXIMReset(root_context->IMC.hWnd);
- send = (root_context->IMC.hCompStr!=NULL); + lpCompStr = ImmLockIMCC(root_context->IMC.hCompStr); + send = (lpCompStr->dwCompStrLen != 0); + ImmUnlockIMCC(root_context->IMC.hCompStr);
ImmDestroyIMCC(root_context->IMC.hCompStr); - root_context->IMC.hCompStr = NULL; + root_context->IMC.hCompStr = ImmCreateBlankCompStr();
if (send) ImmInternalPostIMEMessage(WM_IME_COMPOSITION, 0,