Commit c6dd1f15 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

kernel32: GetConsoleInputExeNameW returns TRUE even when it fails.

parent d296c185
...@@ -1013,14 +1013,15 @@ BOOL WINAPI GetConsoleInputExeNameW(DWORD buflen, LPWSTR buffer) ...@@ -1013,14 +1013,15 @@ BOOL WINAPI GetConsoleInputExeNameW(DWORD buflen, LPWSTR buffer)
*/ */
BOOL WINAPI GetConsoleInputExeNameA(DWORD buflen, LPSTR buffer) BOOL WINAPI GetConsoleInputExeNameA(DWORD buflen, LPSTR buffer)
{ {
WCHAR *bufferW; TRACE("%u %p\n", buflen, buffer);
BOOL ret;
if (!(bufferW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflen))) return FALSE; RtlEnterCriticalSection(&CONSOLE_CritSect);
if ((ret = GetConsoleInputExeNameW(buflen, bufferW))) if (WideCharToMultiByte(CP_ACP, 0, input_exe, -1, NULL, 0, NULL, NULL) <= buflen)
WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, buflen, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, input_exe, -1, buffer, buflen, NULL, NULL);
HeapFree(GetProcessHeap(), 0, bufferW); else SetLastError(ERROR_BUFFER_OVERFLOW);
return ret; RtlLeaveCriticalSection(&CONSOLE_CritSect);
return TRUE;
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment