retitle 469809 Possible memory leak in Document::Init forwarded 469809 http://bugzilla.gnome.org/show_bug.cgi?id=501168 tag 469809 + confirmed thanks
I can confirm the leakage in class xmlpp::Document::Init. But the one in xmlpp::DomParser::parse_file() seems already fixed in newer version. I've made a patch to fix xmlpp::Document::Init from leaking. Please find it in attachment and test. Thanks. Deng Xiyue
diff -urN libxml++-2.20.0/libxml++/document.cc libxml++-2.20.0~/libxml++/document.cc --- libxml++-2.20.0/libxml++/document.cc 2007-08-29 16:22:51.000000000 +0800 +++ libxml++-2.20.0~/libxml++/document.cc 2008-03-07 16:51:17.000000000 +0800 @@ -137,11 +137,16 @@ Document::Init::Init() { - xmlInitParser(); //Not always necessary, but necessary for thread safety. - xmlRegisterNodeDefault(on_libxml_construct); - xmlDeregisterNodeDefault(on_libxml_destruct); - xmlThrDefRegisterNodeDefault(on_libxml_construct); - xmlThrDefDeregisterNodeDefault(on_libxml_destruct); + xmlInitParser(); //Not always necessary, but necessary for thread safety. + xmlRegisterNodeDefault(on_libxml_construct); + xmlDeregisterNodeDefault(on_libxml_destruct); + xmlThrDefRegisterNodeDefault(on_libxml_construct); + xmlThrDefDeregisterNodeDefault(on_libxml_destruct); +} + +Document::Init::~Init() +{ + xmlCleanupParser(); //as per xmlInitParser(), or memory leak will happen. } Document::Init Document::init_; diff -urN libxml++-2.20.0/libxml++/document.h libxml++-2.20.0~/libxml++/document.h --- libxml++-2.20.0/libxml++/document.h 2007-09-11 16:11:24.000000000 +0800 +++ libxml++-2.20.0~/libxml++/document.h 2008-03-07 17:10:31.000000000 +0800 @@ -53,6 +53,7 @@ { public: Init(); + virtual ~Init(); }; friend class DomParser;