Dmitry Timoshkov : user32:
WM_GETTEXT message converters have to 0-terminate output buffer if
there is enough space even if there is no text to convert .
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Mar 22 10:11:09 CDT 2007
Module: wine
Branch: master
Commit: b9eb76dea0fe37cc0f0a4ca7f236b47d7fc98700
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b9eb76dea0fe37cc0f0a4ca7f236b47d7fc98700
Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Thu Mar 22 19:08:21 2007 +0800
user32: WM_GETTEXT message converters have to 0-terminate output buffer if there is enough space even if there is no text to convert.
---
dlls/user32/winproc.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c
index 1d093a9..5a00e51 100644
--- a/dlls/user32/winproc.c
+++ b/dlls/user32/winproc.c
@@ -856,9 +856,11 @@ LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
if (!(ptr = get_buffer( buffer, sizeof(buffer), len ))) break;
ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
- if (*result && wParam)
+ if (wParam)
{
- RtlUnicodeToMultiByteN( str, wParam - 1, &len, ptr, strlenW(ptr) * sizeof(WCHAR) );
+ len = 0;
+ if (*result)
+ RtlUnicodeToMultiByteN( str, wParam - 1, &len, ptr, strlenW(ptr) * sizeof(WCHAR) );
str[len] = 0;
*result = len;
}
@@ -1091,10 +1093,13 @@ static LRESULT WINPROC_CallProcWtoA( winproc_callback_t callback, HWND hwnd, UIN
if (!(ptr = get_buffer( buffer, sizeof(buffer), len ))) break;
ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
- if (*result && len)
+ if (len)
{
- RtlMultiByteToUnicodeN( (LPWSTR)lParam, wParam*sizeof(WCHAR), &len, ptr, strlen(ptr)+1 );
- *result = len/sizeof(WCHAR) - 1; /* do not count terminating null */
+ if (*result)
+ {
+ RtlMultiByteToUnicodeN( (LPWSTR)lParam, wParam*sizeof(WCHAR), &len, ptr, strlen(ptr)+1 );
+ *result = len/sizeof(WCHAR) - 1; /* do not count terminating null */
+ }
((LPWSTR)lParam)[*result] = 0;
}
free_buffer( buffer, ptr );
More information about the wine-cvs
mailing list