Handle FormatMessage failures from LoadLibrary oddities (bug 3760, r=fyren).

This commit is contained in:
David Anderson 2009-03-29 09:01:40 -04:00
parent 3ac9ecb4b7
commit 16756e550f

View File

@ -285,14 +285,16 @@ void LibrarySystem::GetPlatformErrorEx(int code, char *error, size_t maxlength)
if (error && maxlength) if (error && maxlength)
{ {
#if defined PLATFORM_WINDOWS #if defined PLATFORM_WINDOWS
FormatMessageA( if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
NULL, (DWORD)code,
(DWORD)code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)error,
(LPSTR)error, maxlength,
maxlength, NULL) == 0)
NULL); {
UTIL_Format(error, maxlength, "error code %08x", code);
}
#elif defined PLATFORM_LINUX #elif defined PLATFORM_LINUX
const char *ae = strerror_r(code, error, maxlength); const char *ae = strerror_r(code, error, maxlength);
if (ae != error) if (ae != error)