-
Notifications
You must be signed in to change notification settings - Fork 34
Memory leak with ticpp::Element::GetDocument() #61
Comments
Original comment by |
|
Original comment by |
Original comment by |
I found the same issue with the ticpp::Document document;
document.Parse(xmlString);
// Pick one of the next 2 lines, not both
auto node = document.FirstChild();
auto node = document.FirstChild()->FirstChild();
auto parent = node->Parent(); // parent is now either a Document or an Element In the case where Re-assigning the pointer with *parent = ticpp::Document() as described above does not fix the issue for me; the leak remains. What does fix the issue is parent->~Node(); but, as anyone will tell me, explicitly calling a destructor is a bad idea. So am I using the library wrong, or is there a bug? |
Also, I can confirm the following piece of code also causes a leak, as described by the OP: ticpp::Document document;
document.Parse(xmlString);
auto document2 = document.GetDocument(); and that, as above, document2->~Node(); fixes the leak, whereas delete document2; causes a double-free. In this case, where *document2 = ticpp::Document(); does fix the memory leak, as suggested by OP, unlike in my previous example, where reassigning |
Good news: adding In both cases, neither I don't know whether this change has any other, unwanted effects, or why the code doesn't do this already. The I'll make a PR and hopefully get feedback of some kind... |
Original issue reported on code.google.com by
[email protected]
on 20 Nov 2010 at 4:53The text was updated successfully, but these errors were encountered: