BUG: FormatMessage can return a NULL message. Add check for NULL pointer.
This commit is contained in:
parent
bed3ac8741
commit
0d845b8da8
|
@ -305,7 +305,7 @@ const char* DynamicLoader::LibExtension()
|
|||
//----------------------------------------------------------------------------
|
||||
const char* DynamicLoader::LastError()
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
LPVOID lpMsgBuf=NULL;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
|
@ -317,6 +317,11 @@ const char* DynamicLoader::LastError()
|
|||
NULL
|
||||
);
|
||||
|
||||
if(!lpMsgBuf)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char* str = 0;
|
||||
delete [] str;
|
||||
str = strcpy(new char[strlen((char*)lpMsgBuf)+1], (char*)lpMsgBuf);
|
||||
|
|
Loading…
Reference in New Issue