Commit:    444e59eb2071e8c2d2bcb61bb1e2404dd3b780cf
Author:    Remi Collet <r...@php.net>         Thu, 2 May 2013 13:47:24 +0200
Parents:   331540d20cb5b17964e6b2901c343df58bc8a0c9
Branches:  PHP-5.3 PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=444e59eb2071e8c2d2bcb61bb1e2404dd3b780cf

Log:
fix more resource leaks

Changed paths:
  M  sapi/fpm/fpm/fpm_sockets.c
  M  sapi/fpm/fpm/fpm_stdio.c


Diff:
diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c
index f56b9cf..df94967 100644
--- a/sapi/fpm/fpm/fpm_sockets.c
+++ b/sapi/fpm/fpm/fpm_sockets.c
@@ -167,7 +167,7 @@ static int fpm_sockets_new_listening_socket(struct 
fpm_worker_pool_s *wp, struct
 {
        int flags = 1;
        int sock;
-       mode_t saved_umask;
+       mode_t saved_umask = 0;
 
        sock = socket(sa->sa_family, SOCK_STREAM, 0);
 
@@ -181,6 +181,7 @@ static int fpm_sockets_new_listening_socket(struct 
fpm_worker_pool_s *wp, struct
        if (wp->listen_address_domain == FPM_AF_UNIX) {
                if (fpm_socket_unix_test_connect((struct sockaddr_un *)sa, 
socklen) == 0) {
                        zlog(ZLOG_ERROR, "An another FPM instance seems to 
already listen on %s", ((struct sockaddr_un *) sa)->sun_path);
+                       close(sock);
                        return -1;
                }
                unlink( ((struct sockaddr_un *) sa)->sun_path);
@@ -192,6 +193,7 @@ static int fpm_sockets_new_listening_socket(struct 
fpm_worker_pool_s *wp, struct
                if (wp->listen_address_domain == FPM_AF_UNIX) {
                        umask(saved_umask);
                }
+               close(sock);
                return -1;
        }
 
@@ -203,6 +205,7 @@ static int fpm_sockets_new_listening_socket(struct 
fpm_worker_pool_s *wp, struct
                if (wp->socket_uid != -1 || wp->socket_gid != -1) {
                        if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
                                zlog(ZLOG_SYSERROR, "failed to chown() the 
socket '%s'", wp->config->listen_address);
+                               close(sock);
                                return -1;
                        }
                }
@@ -210,6 +213,7 @@ static int fpm_sockets_new_listening_socket(struct 
fpm_worker_pool_s *wp, struct
 
        if (0 > listen(sock, wp->config->listen_backlog)) {
                zlog(ZLOG_SYSERROR, "failed to listen to address '%s'", 
wp->config->listen_address);
+               close(sock);
                return -1;
        }
 
diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c
index 6a587d0..ebe43a2 100644
--- a/sapi/fpm/fpm/fpm_stdio.c
+++ b/sapi/fpm/fpm/fpm_stdio.c
@@ -34,6 +34,7 @@ int fpm_stdio_init_main() /* {{{ */
 
        if (0 > dup2(fd, STDIN_FILENO) || 0 > dup2(fd, STDOUT_FILENO)) {
                zlog(ZLOG_SYSERROR, "failed to init stdio: dup2()");
+               close(fd);
                return -1;
        }
        close(fd);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to