summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-29 09:20:08 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-29 09:20:08 -0700
commitb2399f5ab5b678a59702b77e41692d15410a0c4a (patch)
treef2e896d4552f0c65b61bf8c9999df2c900ab37d6
parent44e4f173480097087a5bffe7ae72857717f11f45 (diff)
Refactor offset_debug
Split a long line into multiple statements.
-rw-r--r--src/pugixml.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index b0e0078..5e09aca 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -6186,7 +6186,12 @@ namespace pugi
// document node always has an offset of 0
if (_root == &doc) return 0;
- return _root->contents && (_root->header & impl::xml_memory_page_contents_allocated_or_shared_mask) == 0 ? _root->contents - doc.buffer : -1;
+ // we need contents to be inside buffer and not shared
+ // if it's shared we don't know if this is the original node
+ if (!_root->contents) return -1;
+ if (_root->header & impl::xml_memory_page_contents_allocated_or_shared_mask) return -1;
+
+ return _root->contents - doc.buffer;
}
#ifdef __BORLANDC__