From 8ede43dcb8331c83389751f6699190da3f3d1d35 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 4 Jul 2015 00:39:55 +0200 Subject: [PATCH] Avoid memory leak in XML parsing. --- src/xml/GXml.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/xml/GXml.cpp b/src/xml/GXml.cpp index c9d2b9f..76ef5c3 100644 --- a/src/xml/GXml.cpp +++ b/src/xml/GXml.cpp @@ -909,8 +909,8 @@ void GXml::process_markup(GXmlNode** current, const std::string& segment) // Append comment markup case MT_COMMENT: { - GXmlComment comment(segment); - (*current)->append(comment); + // Append comment + (*current)->append(GXmlComment(segment)); } break; @@ -956,8 +956,8 @@ void GXml::process_markup(GXmlNode** current, const std::string& segment) // Processing tag case MT_PROCESSING: { - GXmlPI pi(segment); - (*current)->append(pi); + // Append PI + (*current)->append(GXmlPI(segment)); } break; @@ -989,9 +989,8 @@ void GXml::process_text(GXmlNode** current, const std::string& segment) size_t pos = segment.find_first_not_of("\x20\x09\x0d\x0a\x85"); if (pos != std::string::npos) { - // Allocate and append node - GXmlText* node = new GXmlText(segment); - (*current)->append(*node); + // Append node + (*current)->append(GXmlText(segment)); } // endif: there was not only whitespace -- libgit2 0.21.4