Skip to content

Commit fc8e558

Browse files
authored
Merge pull request #2239 from microsoft/fix_malformed_xml_memory_leak
Properly cleanup XML parser contexts upon completion
2 parents dd2d3f7 + 6a5ec1f commit fc8e558

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: apache2/msc_xml.c

+7
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ int xml_complete(modsec_rec *msr, char **error_msg) {
137137
* Frees the resources used for XML parsing.
138138
*/
139139
apr_status_t xml_cleanup(modsec_rec *msr) {
140+
if (msr->xml->parsing_ctx != NULL) {
141+
if (msr->xml->parsing_ctx->myDoc) {
142+
xmlFreeDoc(msr->xml->parsing_ctx->myDoc);
143+
}
144+
xmlFreeParserCtxt(msr->xml->parsing_ctx);
145+
msr->xml->parsing_ctx = NULL;
146+
}
140147
if (msr->xml->doc != NULL) {
141148
xmlFreeDoc(msr->xml->doc);
142149
msr->xml->doc = NULL;

0 commit comments

Comments
 (0)