Skip to content

Commit 046dcfb

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Make MSVCRT memory leak checking usable for the test suite
2 parents a698e36 + 4130fe4 commit 046dcfb

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

Zend/zend_portability.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,12 @@ extern "C++" {
610610
# define ZEND_PREFER_RELOAD
611611
#endif
612612

613+
#if defined(ZEND_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP)
614+
# define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF)
615+
# define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF)
616+
#else
617+
# define ZEND_IGNORE_LEAKS_BEGIN()
618+
# define ZEND_IGNORE_LEAKS_END()
619+
#endif
620+
613621
#endif /* ZEND_PORTABILITY_H */

Zend/zend_strtod.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ Bigint {
546546
static Bigint *freelist[Kmax+1];
547547

548548
static void destroy_freelist(void);
549+
static void free_p5s(void);
549550

550551
#ifdef ZTS
551552
static MUTEX_T dtoa_mutex;
@@ -564,6 +565,8 @@ ZEND_API int zend_startup_strtod(void) /* {{{ */
564565
ZEND_API int zend_shutdown_strtod(void) /* {{{ */
565566
{
566567
destroy_freelist();
568+
free_p5s();
569+
567570
#ifdef ZTS
568571
tsrm_mutex_free(dtoa_mutex);
569572
dtoa_mutex = NULL;
@@ -4540,6 +4543,19 @@ static void destroy_freelist(void)
45404543
FREE_DTOA_LOCK(0)
45414544
}
45424545

4546+
static void free_p5s(void)
4547+
{
4548+
Bigint **listp, *tmp;
4549+
4550+
ACQUIRE_DTOA_LOCK(1)
4551+
listp = &p5s;
4552+
while ((tmp = *listp) != NULL) {
4553+
*listp = tmp->next;
4554+
free(tmp);
4555+
}
4556+
FREE_DTOA_LOCK(1)
4557+
}
4558+
45434559
#ifdef __cplusplus
45444560
}
45454561
#endif

Zend/zend_vm_execute.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59414,13 +59414,17 @@ void zend_vm_init(void)
5941459414
VM_TRACE_START();
5941559415
}
5941659416

59417+
static HashTable *zend_handlers_table = NULL;
59418+
5941759419
void zend_vm_dtor(void)
5941859420
{
5941959421
VM_TRACE_END();
59422+
if (zend_handlers_table) {
59423+
zend_hash_destroy(zend_handlers_table);
59424+
free(zend_handlers_table);
59425+
}
5942059426
}
5942159427

59422-
static HashTable *zend_handlers_table = NULL;
59423-
5942459428
static void init_opcode_serialiser(void)
5942559429
{
5942659430
int i;

Zend/zend_vm_execute.skl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ void {%INITIALIZER_NAME%}(void)
6767
VM_TRACE_START();
6868
}
6969

70+
static HashTable *zend_handlers_table = NULL;
71+
7072
void zend_vm_dtor(void)
7173
{
7274
VM_TRACE_END();
75+
if (zend_handlers_table) {
76+
zend_hash_destroy(zend_handlers_table);
77+
free(zend_handlers_table);
78+
}
7379
}
7480

75-
static HashTable *zend_handlers_table = NULL;
76-
7781
static void init_opcode_serialiser(void)
7882
{
7983
int i;

ext/libxml/config.w32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if (PHP_LIBXML == "yes") {
1616
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
1717
}
1818
PHP_INSTALL_HEADERS("ext/libxml/", "php_libxml.h");
19+
if (PHP_CRT_DEBUG == "yes") {
20+
ADD_FLAG("CFLAGS_LIBXML", "/D PHP_WIN32_DEBUG_HEAP");
21+
}
1922
} else {
2023
WARNING("libxml support can't be enabled, iconv or libxml are missing")
2124
PHP_LIBXML = "no"

ext/libxml/libxml.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,9 @@ PHP_LIBXML_API void php_libxml_initialize(void)
724724
{
725725
if (!_php_libxml_initialized) {
726726
/* we should be the only one's to ever init!! */
727+
ZEND_IGNORE_LEAKS_BEGIN();
727728
xmlInitParser();
729+
ZEND_IGNORE_LEAKS_END();
728730

729731
_php_libxml_default_entity_loader = xmlGetExternalEntityLoader();
730732
xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader);

0 commit comments

Comments
 (0)