user32: Handle error returns from ImmGetCompositionString.

This commit is contained in:
Marcus Meissner 2008-02-17 15:58:06 +01:00 committed by Alexandre Julliard
parent 2ef077e95e
commit f09f03a723
1 changed files with 13 additions and 13 deletions

View File

@ -5347,7 +5347,7 @@ static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es) static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
{ {
DWORD dwBufLen; LONG buflen;
LPWSTR lpCompStr = NULL; LPWSTR lpCompStr = NULL;
HIMC hIMC; HIMC hIMC;
LPSTR lpCompStrAttr = NULL; LPSTR lpCompStrAttr = NULL;
@ -5356,15 +5356,15 @@ static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
if (!(hIMC = ImmGetContext(hwnd))) if (!(hIMC = ImmGetContext(hwnd)))
return; return;
dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0); buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
if (dwBufLen < 0) if (buflen < 0)
{ {
ImmReleaseContext(hwnd, hIMC); ImmReleaseContext(hwnd, hIMC);
return; return;
} }
lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR)); lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen + sizeof(WCHAR));
if (!lpCompStr) if (!lpCompStr)
{ {
ERR("Unable to allocate IME CompositionString\n"); ERR("Unable to allocate IME CompositionString\n");
@ -5372,9 +5372,9 @@ static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
return; return;
} }
if (dwBufLen) if (buflen)
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, dwBufLen); ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
lpCompStr[dwBufLen/sizeof(WCHAR)] = 0; lpCompStr[buflen/sizeof(WCHAR)] = 0;
if (CompFlag & GCS_COMPATTR) if (CompFlag & GCS_COMPATTR)
{ {
@ -5427,21 +5427,21 @@ static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
static void EDIT_GetResultStr(HWND hwnd, EDITSTATE *es) static void EDIT_GetResultStr(HWND hwnd, EDITSTATE *es)
{ {
DWORD dwBufLen; LONG buflen;
LPWSTR lpResultStr; LPWSTR lpResultStr;
HIMC hIMC; HIMC hIMC;
if ( !(hIMC = ImmGetContext(hwnd))) if ( !(hIMC = ImmGetContext(hwnd)))
return; return;
dwBufLen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
if (dwBufLen <= 0) if (buflen <= 0)
{ {
ImmReleaseContext(hwnd, hIMC); ImmReleaseContext(hwnd, hIMC);
return; return;
} }
lpResultStr = HeapAlloc(GetProcessHeap(),0, dwBufLen+sizeof(WCHAR)); lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen+sizeof(WCHAR));
if (!lpResultStr) if (!lpResultStr)
{ {
ERR("Unable to alloc buffer for IME string\n"); ERR("Unable to alloc buffer for IME string\n");
@ -5449,8 +5449,8 @@ static void EDIT_GetResultStr(HWND hwnd, EDITSTATE *es)
return; return;
} }
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, dwBufLen); ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
lpResultStr[dwBufLen/sizeof(WCHAR)] = 0; lpResultStr[buflen/sizeof(WCHAR)] = 0;
/* check for change in composition start */ /* check for change in composition start */
if (es->selection_end < es->composition_start) if (es->selection_end < es->composition_start)