More pointers pre-asserts
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index fc746de..6248f2c 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -623,6 +623,7 @@
void XMLNode::DeleteChildren()
{
while( _firstChild ) {
+ TIXMLASSERT( _firstChild->_document == _document );
XMLNode* node = _firstChild;
Unlink( node );
@@ -634,6 +635,7 @@
void XMLNode::Unlink( XMLNode* child )
{
+ TIXMLASSERT( child->_document == _document );
if ( child == _firstChild ) {
_firstChild = _firstChild->_next;
}
@@ -653,6 +655,7 @@
void XMLNode::DeleteChild( XMLNode* node )
{
+ TIXMLASSERT( node->_document == _document );
TIXMLASSERT( node->_parent == this );
DeleteNode( node );
}
@@ -660,8 +663,10 @@
XMLNode* XMLNode::InsertEndChild( XMLNode* addThis )
{
- if (addThis->_document != _document)
- return 0;
+ if ( addThis->_document != _document ) {
+ TIXMLASSERT( false );
+ return 0;
+ }
if (addThis->_parent)
addThis->_parent->Unlink( addThis );
@@ -691,8 +696,10 @@
XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
{
- if (addThis->_document != _document)
- return 0;
+ if ( addThis->_document != _document ) {
+ TIXMLASSERT( false );
+ return 0;
+ }
if (addThis->_parent)
addThis->_parent->Unlink( addThis );
@@ -723,12 +730,16 @@
XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )
{
- if (addThis->_document != _document)
- return 0;
+ TIXMLASSERT( addThis );
+ if ( addThis->_document != _document ) {
+ TIXMLASSERT( false );
+ return 0;
+ }
- TIXMLASSERT( afterThis->_parent == this );
+ TIXMLASSERT( afterThis );
if ( afterThis->_parent != this ) {
+ TIXMLASSERT( false );
return 0;
}
@@ -944,6 +955,7 @@
bool XMLText::Accept( XMLVisitor* visitor ) const
{
+ TIXMLASSERT( visitor );
return visitor->Visit( *this );
}
@@ -984,6 +996,7 @@
bool XMLComment::ShallowEqual( const XMLNode* compare ) const
{
+ TIXMLASSERT( compare );
const XMLComment* comment = compare->ToComment();
return ( comment && XMLUtil::StringEqual( comment->Value(), Value() ));
}
@@ -991,6 +1004,7 @@
bool XMLComment::Accept( XMLVisitor* visitor ) const
{
+ TIXMLASSERT( visitor );
return visitor->Visit( *this );
}
@@ -1032,6 +1046,7 @@
bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const
{
+ TIXMLASSERT( compare );
const XMLDeclaration* declaration = compare->ToDeclaration();
return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() ));
}
@@ -1040,6 +1055,7 @@
bool XMLDeclaration::Accept( XMLVisitor* visitor ) const
{
+ TIXMLASSERT( visitor );
return visitor->Visit( *this );
}
@@ -1080,6 +1096,7 @@
bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const
{
+ TIXMLASSERT( compare );
const XMLUnknown* unknown = compare->ToUnknown();
return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() ));
}
@@ -1087,6 +1104,7 @@
bool XMLUnknown::Accept( XMLVisitor* visitor ) const
{
+ TIXMLASSERT( visitor );
return visitor->Visit( *this );
}
@@ -1556,6 +1574,7 @@
bool XMLElement::ShallowEqual( const XMLNode* compare ) const
{
+ TIXMLASSERT( compare );
const XMLElement* other = compare->ToElement();
if ( other && XMLUtil::StringEqual( other->Value(), Value() )) {
@@ -1581,6 +1600,7 @@
bool XMLElement::Accept( XMLVisitor* visitor ) const
{
+ TIXMLASSERT( visitor );
if ( visitor->VisitEnter( *this, _rootAttribute ) ) {
for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) {
if ( !node->Accept( visitor ) ) {
@@ -1717,6 +1737,8 @@
static FILE* callfopen( const char* filepath, const char* mode )
{
+ TIXMLASSERT( filepath );
+ TIXMLASSERT( mode );
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
FILE* fp = 0;
errno_t err = fopen_s( &fp, filepath, mode );