diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2008-06-02 23:44:02 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2008-06-02 23:44:02 (GMT) |
commit | 0d845b8da8f13f568d560ed575b6341f6512bc1f (patch) | |
tree | d5b08ff5603b3fb6b71b5784c3a79747610cc332 /Source | |
parent | bed3ac8741405132096430c9f61578df9f8cfbf9 (diff) | |
download | CMake-0d845b8da8f13f568d560ed575b6341f6512bc1f.zip CMake-0d845b8da8f13f568d560ed575b6341f6512bc1f.tar.gz CMake-0d845b8da8f13f568d560ed575b6341f6512bc1f.tar.bz2 |
BUG: FormatMessage can return a NULL message. Add check for NULL pointer.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/DynamicLoader.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index 0c73d7a..1fdcaf0 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -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); |