From 3dc797b2a49742de81bc4e6075c00b414a015f36 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 16 Mar 2015 11:06:46 +0300 Subject: [PATCH] Better asserts in parsing --- tinyxml2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 6d8573b..48383d9 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -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 );