fixed handling of variable arguments and free memory allocated by FormatMessage(). Thanks to Michael Fritscher for spotting this bug.

svn path=/trunk/; revision=9833
This commit is contained in:
Thomas Bluemel 2004-06-23 19:32:17 +00:00
parent a1c2b75227
commit 7ebb752f56

View file

@ -1,4 +1,4 @@
/* $Id: console.c,v 1.6 2004/06/21 18:57:22 weiden Exp $
/* $Id: console.c,v 1.7 2004/06/23 19:32:17 weiden Exp $
*
* CONSOLE.C - console input/output functions.
*
@ -225,17 +225,29 @@ VOID ConPrintf(LPTSTR szFormat, va_list arg_ptr, DWORD nStdHandle)
VOID ConOutFormatMessage (DWORD MessageId, ...)
{
DWORD temp;
DWORD ret;
LPTSTR text;
va_list arg_ptr;
temp = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
va_start (arg_ptr, MessageId);
ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
MessageId,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &text,
0,
&arg_ptr);
ConErrPrintf (text);
va_end (arg_ptr);
if(ret > 0)
{
ConErrPuts (text);
LocalFree(text);
}
else
{
ConErrPrintf (_T("Unknown error: %d\n"), MessageId);
}
}
VOID ConOutPrintf (LPTSTR szFormat, ...)