Re: windows/winproc.c: Get rid of HEAP_strdupWtoA calls
"Jacek Caban" <jack(a)itma.pwr.wroc.pl> wrote:
@@ -1010,9 +1009,15 @@ static INT WINPROC_MapMsg32WTo32A( HWND case LB_DIR: case LB_ADDFILE: case EM_REPLACESEL: - if(!*plparam) return 0; - *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); - return (*plparam ? 1 : -1); + if(*plparam) { + LPSTR buf; + int len = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)*plparam, -1, NULL, 0, 0, 0); + buf = HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR)); + WideCharToMultiByte(CP_ACP, 0, (LPWSTR)*plparam, -1, buf, len, 0, 0); + *plparam = (LPARAM)buf; + return 1; + } + return 0;
It would be helpful to keep the test in the case of a buffer allocation failure here and everywhere else (and perhaps add the missing tests). -- Dmitry.
participants (1)
-
Dmitry Timoshkov