Fix infinite loop bug in ShallowEqual. Fix a warning with a re-interpret cast. Up version to 1.0.4

This commit is contained in:
Lee Thomason (grinliz) 2012-07-01 21:22:53 -07:00
parent a3efec0449
commit 390e978da1
5 changed files with 31 additions and 7 deletions

View File

@ -10,7 +10,7 @@ include(GNUInstallDirs)
################################ ################################
# set lib version here # set lib version here
set(GENERIC_LIB_VERSION "1.0.3") set(GENERIC_LIB_VERSION "1.0.4")
set(GENERIC_LIB_SOVERSION "1") set(GENERIC_LIB_SOVERSION "1")

2
dox
View File

@ -32,7 +32,7 @@ PROJECT_NAME = "TinyXML-2"
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = 1.0.3 PROJECT_NUMBER = 1.0.4
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer # for a project that appears at the top of each page and should give viewer

View File

@ -1242,6 +1242,8 @@ bool XMLElement::ShallowEqual( const XMLNode* compare ) const
if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) {
return false; return false;
} }
a = a->Next();
b = b->Next();
} }
if ( a || b ) { if ( a || b ) {
// different count // different count

View File

@ -85,7 +85,7 @@ distribution.
static const int TIXML2_MAJOR_VERSION = 1; static const int TIXML2_MAJOR_VERSION = 1;
static const int TIXML2_MINOR_VERSION = 0; static const int TIXML2_MINOR_VERSION = 0;
static const int TIXML2_PATCH_VERSION = 3; static const int TIXML2_PATCH_VERSION = 4;
namespace tinyxml2 namespace tinyxml2
{ {
@ -363,8 +363,8 @@ class XMLUtil
public: public:
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
// correct, but simple, and usually works. // correct, but simple, and usually works.
static const char* SkipWhiteSpace( const char* p ) { while( !IsUTF8Continuation(*p) && isspace( *p ) ) { ++p; } return p; } static const char* SkipWhiteSpace( const char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) { ++p; } return p; }
static char* SkipWhiteSpace( char* p ) { while( !IsUTF8Continuation(*p) && isspace( *p ) ) { ++p; } return p; } static char* SkipWhiteSpace( char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) { ++p; } return p; }
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
int n = 0; int n = 0;

View File

@ -793,6 +793,28 @@ int main( int /*argc*/, const char ** /*argv*/ )
XMLTest( "Attribute order (empty)", false, ele->FirstAttribute() ? true : false ); XMLTest( "Attribute order (empty)", false, ele->FirstAttribute() ? true : false );
} }
{
// Make sure an attribute with a space in it succeeds.
static const char* xml = "<element attribute1=\"Test Attribute\"/>";
XMLDocument doc;
doc.Parse( xml );
XMLElement* ele = doc.FirstChildElement();
XMLTest( "Attribute with space", "Test Attribute", ele->Attribute( "attribute1" ) );
}
{
// Make sure we don't go into an infinite loop.
static const char* xml = "<doc><element attribute='attribute'/><element attribute='attribute'/></doc>";
XMLDocument doc;
doc.Parse( xml );
XMLElement* ele0 = doc.FirstChildElement()->FirstChildElement();
XMLElement* ele1 = ele0->NextSiblingElement();
bool equal = ele0->ShallowEqual( ele1 );
XMLTest( "Infinite loop in shallow equal.", true, equal );
}
// -------- Handles ------------ // -------- Handles ------------
{ {
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>"; static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";