1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-29 15:13:01 +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
+7 -1
View File
@@ -2025,7 +2025,13 @@ 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
{
XMLDocument doc(true, PEDANTIC_WHITESPACE);