Skip to content

Commit 00e1b1c

Browse files
committed
Ignore further libxml leaks; update ignore leak macros
We cater to two more potentially leaking libxml functions. We also need to update the `ZEND_IGNORE_LEAKS_BEGIN|END()` macros, since we now have to cater to recursion, so we need to store the original value of `_crtDbgFlag` and reset it afterwards.
1 parent 1e44f49 commit 00e1b1c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Zend/zend_portability.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,11 @@ extern "C++" {
733733
#endif
734734

735735
#if defined(ZEND_WIN32) && defined(_DEBUG)
736-
# define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF)
737-
# define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF)
736+
# define ZEND_IGNORE_LEAKS_BEGIN() \
737+
int zend_crtDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \
738+
_CrtSetDbgFlag(zend_crtDbgFlag & ~_CRTDBG_ALLOC_MEM_DF)
739+
# define ZEND_IGNORE_LEAKS_END() \
740+
_CrtSetDbgFlag(zend_crtDbgFlag)
738741
#else
739742
# define ZEND_IGNORE_LEAKS_BEGIN()
740743
# define ZEND_IGNORE_LEAKS_END()

ext/dom/document.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,9 @@ static void dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type)
19171917
(xmlSchemaValidityErrorFunc) php_libxml_error_handler,
19181918
(xmlSchemaValidityWarningFunc) php_libxml_error_handler,
19191919
parser);
1920+
ZEND_IGNORE_LEAKS_BEGIN();
19201921
sptr = xmlSchemaParse(parser);
1922+
ZEND_IGNORE_LEAKS_END();
19211923
xmlSchemaFreeParserCtxt(parser);
19221924
PHP_LIBXML_RESTORE_GLOBALS(new_parser_ctxt);
19231925
if (!sptr) {

ext/xmlreader/php_xmlreader.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static xmlRelaxNGPtr _xmlreader_get_relaxNG(char *source, size_t source_len, siz
337337
ZEND_IGNORE_LEAKS_BEGIN();
338338
sptr = xmlRelaxNGParse(parser);
339339
ZEND_IGNORE_LEAKS_END();
340-
340+
341341
xmlRelaxNGFreeParserCtxt(parser);
342342
PHP_LIBXML_RESTORE_GLOBALS(parse);
343343

@@ -1085,7 +1085,9 @@ PHP_METHOD(XMLReader, setSchema)
10851085
intern = Z_XMLREADER_P(id);
10861086
if (intern && intern->ptr) {
10871087
PHP_LIBXML_SANITIZE_GLOBALS(schema);
1088+
ZEND_IGNORE_LEAKS_BEGIN();
10881089
retval = xmlTextReaderSchemaValidate(intern->ptr, source);
1090+
ZEND_IGNORE_LEAKS_END();
10891091
PHP_LIBXML_RESTORE_GLOBALS(schema);
10901092

10911093
if (retval == 0) {

0 commit comments

Comments
 (0)