Skip to content

Commit 10b2b4a

Browse files
danogbukka
authored andcommitted
Fix memory leak in standard syslog device handling
The BG(syslog_device) is leaked in RINIT. Closes GH-12501
1 parent 55dfc29 commit 10b2b4a

File tree

4 files changed

+4
-29
lines changed

4 files changed

+4
-29
lines changed

NEWS

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.1.27
44

5-
5+
- Standard:
6+
. Fix memory leak in syslog device handling. (danog)
67

78
23 Nov 2023, PHP 8.1.26
89

ext/standard/basic_functions.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
427427

428428
PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */
429429
{
430-
#ifdef HAVE_SYSLOG_H
431-
PHP_MSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
432-
#endif
433430
#ifdef ZTS
434431
ts_free_id(basic_globals_id);
435432
#ifdef PHP_WIN32
@@ -487,9 +484,6 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */
487484
BG(user_shutdown_function_names) = NULL;
488485

489486
PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
490-
#ifdef HAVE_SYSLOG_H
491-
BASIC_RINIT_SUBMODULE(syslog)
492-
#endif
493487
BASIC_RINIT_SUBMODULE(dir)
494488
BASIC_RINIT_SUBMODULE(url_scanner_ex)
495489

@@ -541,9 +535,7 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */
541535

542536
PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
543537
#ifdef HAVE_SYSLOG_H
544-
#ifdef PHP_WIN32
545-
BASIC_RSHUTDOWN_SUBMODULE(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
546-
#endif
538+
BASIC_RSHUTDOWN_SUBMODULE(syslog);
547539
#endif
548540
BASIC_RSHUTDOWN_SUBMODULE(assert)
549541
BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex)

ext/standard/php_ext_syslog.h

-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
#include "php_syslog.h"
2323

2424
PHP_MINIT_FUNCTION(syslog);
25-
PHP_RINIT_FUNCTION(syslog);
26-
#ifdef PHP_WIN32
2725
PHP_RSHUTDOWN_FUNCTION(syslog);
28-
#endif
29-
PHP_MSHUTDOWN_FUNCTION(syslog);
3026

3127
#endif
3228

ext/standard/syslog.c

+1-15
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,9 @@ PHP_MINIT_FUNCTION(syslog)
9696
}
9797
/* }}} */
9898

99-
PHP_RINIT_FUNCTION(syslog)
100-
{
101-
BG(syslog_device) = NULL;
102-
return SUCCESS;
103-
}
104-
105-
106-
#ifdef PHP_WIN32
10799
PHP_RSHUTDOWN_FUNCTION(syslog)
108100
{
109-
closelog();
110-
return SUCCESS;
111-
}
112-
#endif
113-
114-
PHP_MSHUTDOWN_FUNCTION(syslog)
115-
{
101+
php_closelog();
116102
if (BG(syslog_device)) {
117103
free(BG(syslog_device));
118104
BG(syslog_device) = NULL;

0 commit comments

Comments
 (0)