kernel32: GetConsoleInputExeNameW returns TRUE even when it fails.

This commit is contained in:
Hans Leidekker 2007-12-08 22:54:27 +01:00 committed by Alexandre Julliard
parent d296c18587
commit c6dd1f1599
1 changed files with 8 additions and 7 deletions

View File

@ -1013,14 +1013,15 @@ BOOL WINAPI GetConsoleInputExeNameW(DWORD buflen, LPWSTR buffer)
*/
BOOL WINAPI GetConsoleInputExeNameA(DWORD buflen, LPSTR buffer)
{
WCHAR *bufferW;
BOOL ret;
TRACE("%u %p\n", buflen, buffer);
if (!(bufferW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflen))) return FALSE;
if ((ret = GetConsoleInputExeNameW(buflen, bufferW)))
WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, buflen, NULL, NULL);
HeapFree(GetProcessHeap(), 0, bufferW);
return ret;
RtlEnterCriticalSection(&CONSOLE_CritSect);
if (WideCharToMultiByte(CP_ACP, 0, input_exe, -1, NULL, 0, NULL, NULL) <= buflen)
WideCharToMultiByte(CP_ACP, 0, input_exe, -1, buffer, buflen, NULL, NULL);
else SetLastError(ERROR_BUFFER_OVERFLOW);
RtlLeaveCriticalSection(&CONSOLE_CritSect);
return TRUE;
}
/***********************************************************************