summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-11-05 09:52:12 +0100
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-11-05 09:52:12 +0100
commite3c215b542793ea74e6b2a5ffee2a96695ea9d8c (patch)
tree017052e0d12dff1336ade4fc660d4b1dc626dc33 /src/pugixml.cpp
parentaa1a61c59f2064592d3000a241b01f7ff4bbe0a8 (diff)
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.
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r--src/pugixml.cpp2
1 files changed, 2 insertions, 0 deletions
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);