Verify that compact page encoding is safe
Since page size can be customized let's do a special validation check for compact encoding. Right now it's redundant since page size is limited by 64k in alloc_string, but that may change in the future.
This commit is contained in:
parent
224b9b7ba7
commit
56349939e4
@ -667,6 +667,8 @@ PUGI__NS_BEGIN
|
|||||||
public:
|
public:
|
||||||
compact_header(xml_memory_page* page, unsigned int flags)
|
compact_header(xml_memory_page* page, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
PUGI__STATIC_ASSERT(sizeof(xml_memory_page) + xml_memory_page_size <= (1 << (16 + compact_alignment_log2)));
|
||||||
|
|
||||||
ptrdiff_t page_offset = (reinterpret_cast<char*>(this) - reinterpret_cast<char*>(page)) >> compact_alignment_log2;
|
ptrdiff_t page_offset = (reinterpret_cast<char*>(this) - reinterpret_cast<char*>(page)) >> compact_alignment_log2;
|
||||||
assert(page_offset >= 0 && page_offset < (1 << 16));
|
assert(page_offset >= 0 && page_offset < (1 << 16));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user