From 8e65f5069885ea2e866f6c84f2b5bcad6dd8f3c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Tue, 30 Nov 2010 19:37:10 +0000 Subject: [PATCH] - Fixed bug #53412 (segfault when using -y) --- sapi/fpm/fpm/fpm.c | 4 +++- sapi/fpm/fpm/fpm_conf.c | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index 60e8e4ef3a..17a215c888 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -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() || diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 2389fc6759..f38227c2f2 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -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; -- 2.40.0