From b4ee9fa77f8ac5e556c02ef659b4e6f7ffda62bf Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 23 Oct 2023 21:36:01 +0200 Subject: [PATCH 1/2] Fix memory leak in syslog extension --- ext/standard/basic_functions.c | 8 -------- ext/standard/php_ext_syslog.h | 4 ---- ext/standard/syslog.c | 16 +--------------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 1e50a37f2c687..a7a0c603fb1a7 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -427,9 +427,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */ { -#ifdef HAVE_SYSLOG_H - PHP_MSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); -#endif #ifdef ZTS ts_free_id(basic_globals_id); #ifdef PHP_WIN32 @@ -487,9 +484,6 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ BG(user_shutdown_function_names) = NULL; PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU); -#ifdef HAVE_SYSLOG_H - BASIC_RINIT_SUBMODULE(syslog) -#endif BASIC_RINIT_SUBMODULE(dir) BASIC_RINIT_SUBMODULE(url_scanner_ex) @@ -541,9 +535,7 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #ifdef HAVE_SYSLOG_H -#ifdef PHP_WIN32 BASIC_RSHUTDOWN_SUBMODULE(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); -#endif #endif BASIC_RSHUTDOWN_SUBMODULE(assert) BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex) diff --git a/ext/standard/php_ext_syslog.h b/ext/standard/php_ext_syslog.h index 5e091fb5280df..fd7958fad2929 100644 --- a/ext/standard/php_ext_syslog.h +++ b/ext/standard/php_ext_syslog.h @@ -22,11 +22,7 @@ #include "php_syslog.h" PHP_MINIT_FUNCTION(syslog); -PHP_RINIT_FUNCTION(syslog); -#ifdef PHP_WIN32 PHP_RSHUTDOWN_FUNCTION(syslog); -#endif -PHP_MSHUTDOWN_FUNCTION(syslog); #endif diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c index 70fa8e241abdd..6ea10cef24711 100644 --- a/ext/standard/syslog.c +++ b/ext/standard/syslog.c @@ -96,23 +96,9 @@ PHP_MINIT_FUNCTION(syslog) } /* }}} */ -PHP_RINIT_FUNCTION(syslog) -{ - BG(syslog_device) = NULL; - return SUCCESS; -} - - -#ifdef PHP_WIN32 PHP_RSHUTDOWN_FUNCTION(syslog) { - closelog(); - return SUCCESS; -} -#endif - -PHP_MSHUTDOWN_FUNCTION(syslog) -{ + php_closelog(); if (BG(syslog_device)) { free(BG(syslog_device)); BG(syslog_device) = NULL; From 85fb819daea6f7b6b41d4031ac3ce7bbc55e307b Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 24 Oct 2023 00:01:34 +0200 Subject: [PATCH 2/2] Fix --- ext/standard/basic_functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index a7a0c603fb1a7..cdffeebed66a2 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -535,7 +535,7 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #ifdef HAVE_SYSLOG_H - BASIC_RSHUTDOWN_SUBMODULE(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(syslog); #endif BASIC_RSHUTDOWN_SUBMODULE(assert) BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex)