Commit 8ede43dcb8331c83389751f6699190da3f3d1d35
1 parent
f00028c2
Avoid memory leak in XML parsing.
Showing
1 changed file
with
6 additions
and
7 deletions
src/xml/GXml.cpp
| @@ -909,8 +909,8 @@ void GXml::process_markup(GXmlNode** current, const std::string& segment) | @@ -909,8 +909,8 @@ void GXml::process_markup(GXmlNode** current, const std::string& segment) | ||
| 909 | // Append comment markup | 909 | // Append comment markup |
| 910 | case MT_COMMENT: | 910 | case MT_COMMENT: |
| 911 | { | 911 | { |
| 912 | - GXmlComment comment(segment); | ||
| 913 | - (*current)->append(comment); | 912 | + // Append comment |
| 913 | + (*current)->append(GXmlComment(segment)); | ||
| 914 | } | 914 | } |
| 915 | break; | 915 | break; |
| 916 | 916 | ||
| @@ -956,8 +956,8 @@ void GXml::process_markup(GXmlNode** current, const std::string& segment) | @@ -956,8 +956,8 @@ void GXml::process_markup(GXmlNode** current, const std::string& segment) | ||
| 956 | // Processing tag | 956 | // Processing tag |
| 957 | case MT_PROCESSING: | 957 | case MT_PROCESSING: |
| 958 | { | 958 | { |
| 959 | - GXmlPI pi(segment); | ||
| 960 | - (*current)->append(pi); | 959 | + // Append PI |
| 960 | + (*current)->append(GXmlPI(segment)); | ||
| 961 | } | 961 | } |
| 962 | break; | 962 | break; |
| 963 | 963 | ||
| @@ -989,9 +989,8 @@ void GXml::process_text(GXmlNode** current, const std::string& segment) | @@ -989,9 +989,8 @@ void GXml::process_text(GXmlNode** current, const std::string& segment) | ||
| 989 | size_t pos = segment.find_first_not_of("\x20\x09\x0d\x0a\x85"); | 989 | size_t pos = segment.find_first_not_of("\x20\x09\x0d\x0a\x85"); |
| 990 | if (pos != std::string::npos) { | 990 | if (pos != std::string::npos) { |
| 991 | 991 | ||
| 992 | - // Allocate and append node | ||
| 993 | - GXmlText* node = new GXmlText(segment); | ||
| 994 | - (*current)->append(*node); | 992 | + // Append node |
| 993 | + (*current)->append(GXmlText(segment)); | ||
| 995 | 994 | ||
| 996 | } // endif: there was not only whitespace | 995 | } // endif: there was not only whitespace |
| 997 | 996 |