mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Merge pull request #2239 from microsoft/fix_malformed_xml_memory_leak
Properly cleanup XML parser contexts upon completion
This commit is contained in:
@@ -137,6 +137,13 @@ int xml_complete(modsec_rec *msr, char **error_msg) {
|
|||||||
* Frees the resources used for XML parsing.
|
* Frees the resources used for XML parsing.
|
||||||
*/
|
*/
|
||||||
apr_status_t xml_cleanup(modsec_rec *msr) {
|
apr_status_t xml_cleanup(modsec_rec *msr) {
|
||||||
|
if (msr->xml->parsing_ctx != NULL) {
|
||||||
|
if (msr->xml->parsing_ctx->myDoc) {
|
||||||
|
xmlFreeDoc(msr->xml->parsing_ctx->myDoc);
|
||||||
|
}
|
||||||
|
xmlFreeParserCtxt(msr->xml->parsing_ctx);
|
||||||
|
msr->xml->parsing_ctx = NULL;
|
||||||
|
}
|
||||||
if (msr->xml->doc != NULL) {
|
if (msr->xml->doc != NULL) {
|
||||||
xmlFreeDoc(msr->xml->doc);
|
xmlFreeDoc(msr->xml->doc);
|
||||||
msr->xml->doc = NULL;
|
msr->xml->doc = NULL;
|
||||||
|
Reference in New Issue
Block a user