Merge pull request #297 from Dmitry-Me/betterAssertsInParsing

Better asserts in parsing
This commit is contained in:
Lee Thomason 2015-03-16 11:57:13 -07:00
commit 5ea1cf33f3
1 changed files with 2 additions and 1 deletions

View File

@ -397,8 +397,8 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
else {
return 0;
}
TIXMLASSERT( digit >= 0 && digit < 16);
TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
TIXMLASSERT( digit >= 0 && digit < 16);
const unsigned int digitScaled = mult * digit;
TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );
ucs += digitScaled;
@ -427,6 +427,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
while ( *q != '#' ) {
if ( *q >= '0' && *q <= '9' ) {
const unsigned int digit = *q - '0';
TIXMLASSERT( digit >= 0 && digit < 10);
TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
const unsigned int digitScaled = mult * digit;
TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );