com php-src: MFH: Fixed fd leak (the origin commit can not be cherry-picked): ext/opcache/zend_file_cache.c main/fast cgi.c sapi/cli/ps_title.c
sapi/phpdbg/phpdbg.c
| From: | Xinchen Hui | Date: | Tue, 28 Jun 2016 03:36:27 +0000 |
| Subject: | com php-src: MFH: Fixed fd leak (the origin commit can not be cherry-picked): ext/opcache/zend_file_cache.c main/fast cgi.c sapi/cli/ps_title.c sapi/phpdbg/phpdbg.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92686@lists.php.net to get a copy of this message | ||
Commit: de7a6b1232ac863fb604cdec361a6b7e8e94384e
Author: Xinchen Hui <laruence@gmail.com> Tue, 28 Jun 2016 11:32:41 +0800
Parents: 86732b4ea0dc0ce0a98096467eea5bb0d2eab1d1
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=de7a6b1232ac863fb604cdec361a6b7e8e94384e
Log:
MFH: Fixed fd leak (the origin commit can not be cherry-picked)
Changed paths:
M ext/opcache/zend_file_cache.c
M main/fastcgi.c
M sapi/cli/ps_title.c
M sapi/phpdbg/phpdbg.c
Diff:
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 3187412..b8e9b18 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -773,6 +773,7 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
if (writev(fd, vec, 3) != (ssize_t)(sizeof(info) + script->size + info.str_size)) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot write to file '%s'\n",
filename);
zend_string_release((zend_string*)ZCG(mem));
+ close(fd);
efree(mem);
unlink(filename);
efree(filename);
@@ -786,6 +787,7 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot write to file '%s'\n",
filename);
zend_string_release((zend_string*)ZCG(mem));
+ close(fd);
efree(mem);
unlink(filename);
efree(filename);
diff --git a/main/fastcgi.c b/main/fastcgi.c
index 8fc7d6a..d2e1225 100644
--- a/main/fastcgi.c
+++ b/main/fastcgi.c
@@ -757,7 +757,7 @@ int fcgi_listen(const char *path, int backlog)
#endif
bind(listen_socket, (struct sockaddr *) &sa, sock_len) < 0 ||
listen(listen_socket, backlog) < 0) {
-
+ close(listen_socket);
fcgi_log(FCGI_ERROR, "Cannot bind/listen socket - [%d] %s.\n",errno, strerror(errno));
return -1;
}
diff --git a/sapi/cli/ps_title.c b/sapi/cli/ps_title.c
index 2d95e49..15ab044 100644
--- a/sapi/cli/ps_title.c
+++ b/sapi/cli/ps_title.c
@@ -224,8 +224,10 @@ char** save_ps_args(int argc, char** argv)
for (i = 0; i < argc; i++)
{
new_argv[i] = strdup(argv[i]);
- if (!new_argv[i])
+ if (!new_argv[i]) {
+ free(new_argv);
goto clobber_error;
+ }
}
new_argv[argc] = NULL;
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 68a164c..9b7993d 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1439,6 +1439,7 @@ phpdbg_main:
case 'i': { /* set init file */
if (init_file) {
free(init_file);
+ init_file = NULL;
}
init_file_len = strlen(php_optarg);
@@ -1792,7 +1793,9 @@ phpdbg_main:
/* initialize from file */
PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
zend_try {
- phpdbg_init(init_file, init_file_len, init_file_default);
+ if (init_file) {
+ phpdbg_init(init_file, init_file_len, init_file_default);
+ }
if (bp_tmp) {
PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
phpdbg_string_init(bp_tmp);