-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The xml_allocator::deallocate_memory is NOT reentrant #651
Comments
Freeing the same pointer multiple times is invalid. |
I fix the bug as follow:
2
3
4 In method xml_allocator::deallocate_memory, change code
... |
If a removed xml_node instance be removed multple times will cause deallocate_memory be called multiply times. |
First, this is invalid code; it's somewhat similar to double-free or double-delete in C++. Quoting pugixml manual:
Second, attempting to do this will generally speaking cleanly fail ( |
A removed xml_node instance named _node.
call deallocate_string will cause call deallocate_memory and the memory leaked. |
Ah, yeah, the internal structure of nodes is not cleared in some cases after removal to improve performance of destroying large trees. Again, all of the operations on removed nodes are invalid; this is use after free. If you want to get better diagnostics for the case above I think you can try to change |
The xml_allocator::deallocate_memory is NOT reentrant, if called multiply time with same parameter ptr, page->freed_size += size will be executed multiply times, will cause page->freed_size > page->busy_size, the page will never deallocated. the memory will leaked.
The text was updated successfully, but these errors were encountered: