Fix invalid assertion in XPath: reallocation can result in allocating buffer of the same size due to pointer-sized alignment
git-svn-id: http://pugixml.googlecode.com/svn/trunk@946 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
28def6fbca
commit
4e1add1a46
2 changed files with 15 additions and 1 deletions
|
@ -5825,7 +5825,7 @@ PUGI__NS_BEGIN
|
|||
if (result != ptr && ptr)
|
||||
{
|
||||
// copy old data
|
||||
assert(new_size > old_size);
|
||||
assert(new_size >= old_size);
|
||||
memcpy(result, ptr, old_size);
|
||||
|
||||
// free the previous page if it had no other objects
|
||||
|
|
|
@ -420,4 +420,18 @@ TEST_XML(xpath_out_of_memory_evaluate_predicate, "<node><a/><a/><a/><a/><a/><a/>
|
|||
#endif
|
||||
}
|
||||
|
||||
TEST(xpath_memory_concat_massive)
|
||||
{
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_node node = doc.append_child(STR("node"));
|
||||
|
||||
for (int i = 0; i < 5000; ++i)
|
||||
node.append_child(STR("c")).text().set(i % 10);
|
||||
|
||||
pugi::xpath_query q(STR("/"));
|
||||
size_t size = q.evaluate_string(0, 0, node);
|
||||
|
||||
CHECK(size == 5001);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue