clone() not working with 'parse_non_destructive'
Brought to you by:
kaalus
The problem occurs when cloning a node/attribute of a document parsed with 'parse_non_destructive' with an empty value (size = 0). Let's take the sample of an attribute: when cloning allocate_attribute is called with 0 as value_size argument. Now the problem is that inside allocate_attribute (and allocate_node) the following check is performed:
if (value_size > 0)
node->value(value, value_size);
else
node->value(value);
In this case the value_size is 0 but it doesn't mean that we need to measure the value size. Doing so will return a wrong size since the document was parsed without adding terminators.
I have attached a small fix for the issue which seems to work correctly.
Thanks!
fix