0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-31 00:13:01 +08:00

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.
This commit is contained in:
Arseny Kapoulkine 2014-11-05 09:52:12 +01:00
parent aa1a61c59f
commit e3c215b542

View File

@ -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);