]> granicus.if.org Git - php/commitdiff
- Fixed bug #53412 (segfault when using -y)
authorJérôme Loyet <fat@php.net>
Tue, 30 Nov 2010 19:37:10 +0000 (19:37 +0000)
committerJérôme Loyet <fat@php.net>
Tue, 30 Nov 2010 19:37:10 +0000 (19:37 +0000)
NEWS
sapi/fpm/fpm/fpm.c
sapi/fpm/fpm/fpm_conf.c

diff --git a/NEWS b/NEWS
index e33da9ecdf652141d8138c0777392053d2889f1e..06447cd5dad2c64ad9d40c018756ae80c7932bea 100644 (file)
--- a/NEWS
+++ b/NEWS
     returns int(0)). (slugonamission at gmail dot com)
    
 - PHP-FPM SAPI:
+  . Fixed bug #53412 (segfault when using -y). (fat)
   . Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat)
   . Fixed bug #52501 (libevent made FPM crashed when forking -- libevent has
     been removed). (fat)
index 60e8e4ef3a73a8e7c25fb37af304aa812a6df9bd..17a215c888cd3d2af381ebe02994f518cbb8f47e 100644 (file)
@@ -27,7 +27,9 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) /
 {
        fpm_globals.argc = argc;
        fpm_globals.argv = argv;
-       fpm_globals.config = config;
+       if (config && *config) {
+               fpm_globals.config = strdup(config);
+       }
        fpm_globals.prefix = prefix;
 
        if (0 > fpm_php_init_main()              ||
index 2389fc6759aafd441c6cdd7a1abf9ae633c64aa0..f38227c2f240304a82734f1e151a057de8863ad6 100644 (file)
@@ -794,7 +794,7 @@ static void fpm_conf_cleanup(int which, void *arg) /* {{{ */
        free(fpm_global_config.error_log);
        fpm_global_config.pid_file = 0;
        fpm_global_config.error_log = 0;
-       efree(fpm_globals.config);
+       free(fpm_globals.config);
 }
 /* }}} */
 
@@ -1179,13 +1179,22 @@ int fpm_conf_init_main(int test_conf) /* {{{ */
        }
 
        if (fpm_globals.config == NULL) {
+               char *tmp;
 
                if (fpm_globals.prefix == NULL) {
-                       spprintf(&fpm_globals.config, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR);
+                       spprintf(&tmp, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR);
                } else {
-                       spprintf(&fpm_globals.config, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix);
+                       spprintf(&tmp, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix);
                }
 
+               if (!tmp) {
+                       zlog(ZLOG_SYSERROR, "spprintf() failed (tmp for fpm_globals.config)");
+                       return -1;
+               }
+
+               fpm_globals.config = strdup(tmp);
+               efree(tmp);
+
                if (!fpm_globals.config) {
                        zlog(ZLOG_SYSERROR, "spprintf() failed (fpm_globals.config)");
                        return -1;