MFH: Fixed fd leak (the origin commit can not be cherry-picked)

This commit is contained in:
Xinchen Hui 2016-06-28 11:32:41 +08:00
parent 86732b4ea0
commit de7a6b1232
4 changed files with 10 additions and 3 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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);