From b2399f5ab5b678a59702b77e41692d15410a0c4a Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 29 Apr 2015 09:20:08 -0700 Subject: Refactor offset_debug Split a long line into multiple statements. --- src/pugixml.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/pugixml.cpp') 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__ -- cgit v1.2.3