Skip to content

Commit 1e44f49

Browse files
committed
Ignore xmlRelaxNGParse() memory leaks
`xmlRelaxNGParse()` calls `xmlRelaxNGInitTypes()` and that allocates memory. libxml2 recommends to call `xmlCleanupParser()` to free this memory, but we don't call this function for reasons.
1 parent a67912a commit 1e44f49

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

ext/dom/document.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,9 @@ static void dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int type
20232023
(xmlRelaxNGValidityErrorFunc) php_libxml_error_handler,
20242024
(xmlRelaxNGValidityWarningFunc) php_libxml_error_handler,
20252025
parser);
2026+
ZEND_IGNORE_LEAKS_BEGIN();
20262027
sptr = xmlRelaxNGParse(parser);
2028+
ZEND_IGNORE_LEAKS_END();
20272029
xmlRelaxNGFreeParserCtxt(parser);
20282030
PHP_LIBXML_RESTORE_GLOBALS(parse);
20292031
if (!sptr) {

ext/xmlreader/php_xmlreader.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,10 @@ static xmlRelaxNGPtr _xmlreader_get_relaxNG(char *source, size_t source_len, siz
334334
(xmlRelaxNGValidityWarningFunc) warn_func,
335335
parser);
336336
}
337+
ZEND_IGNORE_LEAKS_BEGIN();
337338
sptr = xmlRelaxNGParse(parser);
339+
ZEND_IGNORE_LEAKS_END();
340+
338341
xmlRelaxNGFreeParserCtxt(parser);
339342
PHP_LIBXML_RESTORE_GLOBALS(parse);
340343

0 commit comments

Comments
 (0)