From a1beddf48624e6facf4e2fccccd745f954d02a5d Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Tue, 26 May 2015 16:19:21 +0300 Subject: [PATCH] Test error name is non-empty for the whole range --- tinyxml2.cpp | 4 +++- xmltest.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 667170f..286827a 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1964,7 +1964,9 @@ void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) const char* XMLDocument::ErrorName() const { TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT ); - return _errorNames[_errorID]; + const char* errorName = _errorNames[_errorID]; + TIXMLASSERT( errorName && errorName[0] ); + return errorName; } void XMLDocument::PrintError() const diff --git a/xmltest.cpp b/xmltest.cpp index 5e0eb3a..1c04668 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -1498,6 +1498,14 @@ int main( int argc, const char ** argv ) delete doc; } + { + XMLDocument doc; + for( int i = 0; i < XML_ERROR_COUNT; i++ ) { + doc.SetError( (XMLError)i, 0, 0 ); + doc.ErrorName(); + } + } + // ----------- Performance tracking -------------- { #if defined( _MSC_VER )