Skip to content

Commit 6a5ec1f

Browse files
committed
Properly cleanup XML parser contexts upon completion
It is currently possible that the XML parsing context is not properly cleaned up if a parsed XML document is malformed. This fix makes sure that the context is taken care of. Signed-off-by: Vladimir Krivopalov <[email protected]>
1 parent 624bd2b commit 6a5ec1f

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)