From 16756e550fd604dd32f95a186ede3ad8dd63d1a3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 29 Mar 2009 09:01:40 -0400 Subject: [PATCH] Handle FormatMessage failures from LoadLibrary oddities (bug 3760, r=fyren). --- core/LibrarySys.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/LibrarySys.cpp b/core/LibrarySys.cpp index 3615298f..23fefc25 100644 --- a/core/LibrarySys.cpp +++ b/core/LibrarySys.cpp @@ -285,14 +285,16 @@ void LibrarySystem::GetPlatformErrorEx(int code, char *error, size_t maxlength) if (error && maxlength) { #if defined PLATFORM_WINDOWS - FormatMessageA( - FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - (DWORD)code, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)error, - maxlength, - NULL); + if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + (DWORD)code, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)error, + maxlength, + NULL) == 0) + { + UTIL_Format(error, maxlength, "error code %08x", code); + } #elif defined PLATFORM_LINUX const char *ae = strerror_r(code, error, maxlength); if (ae != error)