Merge pull request #273 from Dmitry-Me/moreChecksInUtfConversion

More checks inside UTF conversion
This commit is contained in:
Lee Thomason 2015-01-13 13:39:46 -08:00
commit d95716bd79

View File

@ -351,6 +351,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
if ( *(p+1) == '#' && *(p+2) ) { if ( *(p+1) == '#' && *(p+2) ) {
unsigned long ucs = 0; unsigned long ucs = 0;
TIXMLASSERT( sizeof( ucs ) >= 4 );
ptrdiff_t delta = 0; ptrdiff_t delta = 0;
unsigned mult = 1; unsigned mult = 1;
static const char SEMICOLON = ';'; static const char SEMICOLON = ';';
@ -385,6 +386,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
else { else {
return 0; return 0;
} }
TIXMLASSERT( mult <= UINT_MAX / 16 );
mult *= 16; mult *= 16;
--q; --q;
} }
@ -413,6 +415,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
else { else {
return 0; return 0;
} }
TIXMLASSERT( mult <= UINT_MAX / 10 );
mult *= 10; mult *= 10;
--q; --q;
} }
@ -581,6 +584,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node )
bool XMLDocument::Accept( XMLVisitor* visitor ) const bool XMLDocument::Accept( XMLVisitor* visitor ) const
{ {
TIXMLASSERT( visitor );
if ( visitor->VisitEnter( *this ) ) { if ( visitor->VisitEnter( *this ) ) {
for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) {
if ( !node->Accept( visitor ) ) { if ( !node->Accept( visitor ) ) {