1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-28 22:52:59 +04:00

Fix crash when element is being inserted "after itself"

This commit is contained in:
Dmitry-Me
2017-09-15 19:34:36 +03:00
parent bdad8d73a3
commit e8f4a8b567
2 changed files with 35 additions and 0 deletions
+7
View File
@@ -911,6 +911,13 @@ XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )
TIXMLASSERT( false );
return 0;
}
if ( afterThis == addThis ) {
// Current state: BeforeThis -> AddThis -> OneAfterAddThis
// Now AddThis must disappear from it's location and then
// reappear between BeforeThis and OneAfterAddThis.
// So just leave it where it is.
return addThis;
}
if ( afterThis->_next == 0 ) {
// The last node or the only node.