mirror of
https://github.com/leethomason/tinyxml2.git
synced 2026-07-21 19:23:00 +04:00
Merge branch 'master' of github.com:leethomason/tinyxml2
This commit is contained in:
@@ -114,6 +114,9 @@ distribution.
|
||||
#define TIXML_VSNPRINTF vsnprintf
|
||||
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
||||
{
|
||||
if (!format) {
|
||||
return 0;
|
||||
}
|
||||
int len = vsnprintf( 0, 0, format, va );
|
||||
TIXMLASSERT( len >= 0 );
|
||||
return len;
|
||||
@@ -2347,6 +2350,9 @@ static FILE* callfopen( const char* filepath, const char* mode )
|
||||
void XMLDocument::DeleteNode( XMLNode* node ) {
|
||||
TIXMLASSERT( node );
|
||||
TIXMLASSERT(node->_document == this );
|
||||
if(node == 0) {
|
||||
return; // check for null pointer
|
||||
}
|
||||
if (node->_parent) {
|
||||
node->_parent->DeleteChild( node );
|
||||
}
|
||||
|
||||
@@ -2025,6 +2025,12 @@ int main( int argc, const char ** argv )
|
||||
XMLTest("Parse nested elements with pedantic whitespace", false, doc.Error());
|
||||
XMLTest("Pedantic whitespace", true, 0 == doc.RootElement()->FirstChildElement()->GetText());
|
||||
}
|
||||
//Check the robustness of the DeleteNode function in handling null pointers.
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.DeleteNode(nullptr);
|
||||
XMLTest("DeleteNode with null pointer", true, doc.Error() == XML_SUCCESS);
|
||||
}
|
||||
|
||||
// Check sample xml can be parsed with pedantic mode
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user