medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 27bcb570f0918d4c6fc0595ea246a285f4c58db7
parent 925bebae981eff8131fb4e0b32e4dd3706f766bb
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Sep 14 16:48:55 +0100

Return NULL if GetLastError returns 0

Diffstat:
win32_library.h | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/win32_library.h b/win32_library.h @@ -19,8 +19,13 @@ const char * library_last_error() { * these functions should really only get called by the main thread, so * this should be ok */ + DWORD error = GetLastError(); + if( error == 0 ) { + return NULL; + } + static char buf[ 1024 ]; - FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), + FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), buf, sizeof( buf ), NULL ); return buf; }