Gerald Pfeifer gerald@pfeifer.com writes:
dwBufLen already indictes that this variable is of type DWORD and thus always positive. I also looked at the implementation of ImmGetCompositionStringW() and we do not seem to return a negative value (such as -1).
Maybe the implementation doesn't, but the function returns a LONG, and can (and probably should) return negative values on error.
On Wed, 26 Dec 2007, Alexandre Julliard wrote:
dwBufLen already indictes that this variable is of type DWORD and thus always positive. I also looked at the implementation of ImmGetCompositionStringW() and we do not seem to return a negative value (such as -1).
Maybe the implementation doesn't, but the function returns a LONG, and can (and probably should) return negative values on error.
Okay. In that case, to account for possible future enhancements of ImmGetCompositionStringW(), we'll need a patch like the following. The current error handling code in EDIT_GetCompositionStr() simply doesn't work due to the unsignedness of dwBufLen.
Gerald
ChangeLog: Fix error handling in EDIT_GetCompositionStr().
Index: dlls/user32/edit.c =================================================================== RCS file: /home/wine/wine/dlls/user32/edit.c,v retrieving revision 1.16 diff -u -3 -p -r1.16 edit.c --- dlls/user32/edit.c 20 Nov 2007 16:56:17 -0000 1.16 +++ dlls/user32/edit.c 26 Dec 2007 21:29:33 -0000 @@ -5360,6 +5348,7 @@ static void EDIT_UpdateText(EDITSTATE *e
static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es) { + LONG l; DWORD dwBufLen; LPWSTR lpCompStr = NULL; HIMC hIMC; @@ -5369,9 +5358,9 @@ static void EDIT_GetCompositionStr(HWND if (!(hIMC = ImmGetContext(hwnd))) return;
- dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0); + dwBufLen = l = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
- if (dwBufLen < 0) + if (l < 0) { ImmReleaseContext(hwnd, hIMC); return;
A second one which Marcus ended up reinventing, but at least the underlying problem is solved now. :-/
Gerald
On Wed, 26 Dec 2007, Gerald Pfeifer wrote:
Okay. In that case, to account for possible future enhancements of ImmGetCompositionStringW(), we'll need a patch like the following. The current error handling code in EDIT_GetCompositionStr() simply doesn't work due to the unsignedness of dwBufLen.
Gerald
ChangeLog: Fix error handling in EDIT_GetCompositionStr().
Index: dlls/user32/edit.c
RCS file: /home/wine/wine/dlls/user32/edit.c,v retrieving revision 1.16 diff -u -3 -p -r1.16 edit.c --- dlls/user32/edit.c 20 Nov 2007 16:56:17 -0000 1.16 +++ dlls/user32/edit.c 26 Dec 2007 21:29:33 -0000 @@ -5360,6 +5348,7 @@ static void EDIT_UpdateText(EDITSTATE *e
static void EDIT_GetCompositionStr(HWND hwnd, LPARAM CompFlag, EDITSTATE *es) {
- LONG l; DWORD dwBufLen; LPWSTR lpCompStr = NULL; HIMC hIMC;
@@ -5369,9 +5358,9 @@ static void EDIT_GetCompositionStr(HWND if (!(hIMC = ImmGetContext(hwnd))) return;
- dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
- dwBufLen = l = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
- if (dwBufLen < 0)
- if (l < 0) { ImmReleaseContext(hwnd, hIMC); return;