From e3c215b542793ea74e6b2a5ffee2a96695ea9d8c Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 5 Nov 2014 09:52:12 +0100 Subject: Ensure selected page size works with allocate_string Previously setting a large page size (i.e. 1M) would cause dynamic string allocation to assert spuriously. A page size of 64K guarantees that all offsets fit into 16 bits. --- src/pugixml.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 3fe492b..a3aaf76 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -400,6 +400,8 @@ PUGI__NS_BEGIN char_t* allocate_string(size_t length) { + PUGI__STATIC_ASSERT(xml_memory_page_size <= (1 << 16)); + // allocate memory for string and header block size_t size = sizeof(xml_memory_string_header) + length * sizeof(char_t); -- cgit v1.2.3