From 9f56e12c161d27567ba691c5726c5c390e527448 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 12 Jan 2015 10:07:54 +0300 Subject: [PATCH] strchr() can only find what is was asked for --- tinyxml2.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 90b9e79..99cca41 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -353,6 +353,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) unsigned long ucs = 0; ptrdiff_t delta = 0; unsigned mult = 1; + const char semicolon = ';'; if ( *(p+2) == 'x' ) { // Hexadecimal. @@ -361,11 +362,12 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) } const char* q = p+3; - q = strchr( q, ';' ); + q = strchr( q, semicolon ); - if ( !q || !*q ) { + if ( !q ) { return 0; } + TIXMLASSERT( *q == semicolon ); delta = q-p; --q; @@ -394,11 +396,12 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) } const char* q = p+2; - q = strchr( q, ';' ); + q = strchr( q, semicolon ); - if ( !q || !*q ) { + if ( !q ) { return 0; } + TIXMLASSERT( *q == semicolon ); delta = q-p; --q;