From 4130fe437a5db7ead1444d3748bd0fbad9829cb2 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 15 Jan 2020 23:04:03 +0100 Subject: Make MSVCRT memory leak checking usable for the test suite While basic support for MSVCRT debugging has been added long ago[1], the leak checking is not usable for the test suite, because we are no longer calling `xmlCleanupParser()` on RSHUTDOWN of ext/libxml[2], and therefore a few bogus leaks are reported whenever ext/libxml is unloaded. We therefore ignore memory leaks for this case. We introduce `ZEND_IGNORE_LEAKS_BEGIN()` and `ZEND_IGNORE_LEAKS_END()` to keep those ignores better readable, and also because these *might* be useful for other leak checkers as well. We also explicitly free the `zend_handlers_table` and the `p5s` to avoid spurious leak reports. [1] [2] --- ext/libxml/config.w32 | 3 +++ ext/libxml/libxml.c | 2 ++ 2 files changed, 5 insertions(+) (limited to 'ext/libxml') diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32 index b11c57bc44..dd91c4b893 100644 --- a/ext/libxml/config.w32 +++ b/ext/libxml/config.w32 @@ -16,6 +16,9 @@ if (PHP_LIBXML == "yes") { ADD_DEF_FILE("ext\\libxml\\php_libxml2.def"); } PHP_INSTALL_HEADERS("ext/libxml/", "php_libxml.h"); + if (PHP_CRT_DEBUG == "yes") { + ADD_FLAG("CFLAGS_LIBXML", "/D PHP_WIN32_DEBUG_HEAP"); + } } else { WARNING("libxml support can't be enabled, iconv or libxml are missing") PHP_LIBXML = "no" diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 333dab4856..360d1999e7 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -752,7 +752,9 @@ PHP_LIBXML_API void php_libxml_initialize(void) { if (!_php_libxml_initialized) { /* we should be the only one's to ever init!! */ + ZEND_IGNORE_LEAKS_BEGIN(); xmlInitParser(); + ZEND_IGNORE_LEAKS_END(); _php_libxml_default_entity_loader = xmlGetExternalEntityLoader(); xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader); -- cgit v1.2.1