Skip to content

Ignore libxml leaks #16521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,11 @@ extern "C++" {
#endif

#if defined(ZEND_WIN32) && defined(_DEBUG)
# define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF)
# define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF)
# define ZEND_IGNORE_LEAKS_BEGIN() \
int zend_crtDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \
_CrtSetDbgFlag(zend_crtDbgFlag & ~_CRTDBG_ALLOC_MEM_DF)
# define ZEND_IGNORE_LEAKS_END() \
_CrtSetDbgFlag(zend_crtDbgFlag)
#else
# define ZEND_IGNORE_LEAKS_BEGIN()
# define ZEND_IGNORE_LEAKS_END()
Expand Down
4 changes: 4 additions & 0 deletions ext/dom/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,9 @@ static void dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type)
(xmlSchemaValidityErrorFunc) php_libxml_error_handler,
(xmlSchemaValidityWarningFunc) php_libxml_error_handler,
parser);
ZEND_IGNORE_LEAKS_BEGIN();
sptr = xmlSchemaParse(parser);
ZEND_IGNORE_LEAKS_END();
xmlSchemaFreeParserCtxt(parser);
PHP_LIBXML_RESTORE_GLOBALS(new_parser_ctxt);
if (!sptr) {
Expand Down Expand Up @@ -2023,7 +2025,9 @@ static void dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int type
(xmlRelaxNGValidityErrorFunc) php_libxml_error_handler,
(xmlRelaxNGValidityWarningFunc) php_libxml_error_handler,
parser);
ZEND_IGNORE_LEAKS_BEGIN();
sptr = xmlRelaxNGParse(parser);
ZEND_IGNORE_LEAKS_END();
xmlRelaxNGFreeParserCtxt(parser);
PHP_LIBXML_RESTORE_GLOBALS(parse);
if (!sptr) {
Expand Down
5 changes: 4 additions & 1 deletion ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,10 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,

/* no custom user-land callback set up; delegate to original loader */
if (!ZEND_FCC_INITIALIZED(LIBXML(entity_loader_callback))) {
return _php_libxml_default_entity_loader(URL, ID, context);
ZEND_IGNORE_LEAKS_BEGIN();
ret = _php_libxml_default_entity_loader(URL, ID, context);
ZEND_IGNORE_LEAKS_END();
return ret;
}

if (ID != NULL) {
Expand Down
5 changes: 5 additions & 0 deletions ext/xmlreader/php_xmlreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ static xmlRelaxNGPtr _xmlreader_get_relaxNG(char *source, size_t source_len, siz
(xmlRelaxNGValidityWarningFunc) warn_func,
parser);
}
ZEND_IGNORE_LEAKS_BEGIN();
sptr = xmlRelaxNGParse(parser);
ZEND_IGNORE_LEAKS_END();

xmlRelaxNGFreeParserCtxt(parser);
PHP_LIBXML_RESTORE_GLOBALS(parse);

Expand Down Expand Up @@ -1082,7 +1085,9 @@ PHP_METHOD(XMLReader, setSchema)
intern = Z_XMLREADER_P(id);
if (intern && intern->ptr) {
PHP_LIBXML_SANITIZE_GLOBALS(schema);
ZEND_IGNORE_LEAKS_BEGIN();
retval = xmlTextReaderSchemaValidate(intern->ptr, source);
ZEND_IGNORE_LEAKS_END();
PHP_LIBXML_RESTORE_GLOBALS(schema);

if (retval == 0) {
Expand Down