Fix crash when element is being inserted "after itself"
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index a8a4a20..dcf2a43 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -911,6 +911,13 @@
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.