1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-21 19:23:00 +04:00

Fix issue #1048: Add null pointer check in XMLDocument::DeleteNode (#1057)

- Add null pointer check in XMLDocument::DeleteNode() method
- Add test case to verify null pointer handling
- Prevents segmentation fault when calling DeleteNode(nullptr)
This commit is contained in:
zhthhh
2026-03-10 08:32:22 +08:00
committed by GitHub
parent e48a1310fe
commit aba13c50bf
2 changed files with 11 additions and 2 deletions
+4 -1
View File
@@ -2347,9 +2347,12 @@ static FILE* callfopen( const char* filepath, const char* mode )
return fp;
}
void XMLDocument::DeleteNode( XMLNode* node ) {
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 );
}