summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2016-06-28 11:32:41 +0800
committerXinchen Hui <laruence@gmail.com>2016-06-28 11:36:27 +0800
commitde7a6b1232ac863fb604cdec361a6b7e8e94384e (patch)
tree1cf14dacab0390f04a9fd9183002e01134488fb7
parent86732b4ea0dc0ce0a98096467eea5bb0d2eab1d1 (diff)
downloadphp-git-de7a6b1232ac863fb604cdec361a6b7e8e94384e.tar.gz
MFH: Fixed fd leak (the origin commit can not be cherry-picked)
-rw-r--r--ext/opcache/zend_file_cache.c2
-rw-r--r--main/fastcgi.c2
-rw-r--r--sapi/cli/ps_title.c4
-rw-r--r--sapi/phpdbg/phpdbg.c5
4 files changed, 10 insertions, 3 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 3187412423..b8e9b1800b 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 8fc7d6a968..d2e1225246 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 2d95e494aa..15ab0445d8 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 68a164c499..9b7993ddf0 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);