diff options
author | Jérôme Loyet <fat@php.net> | 2011-07-05 01:43:50 +0000 |
---|---|---|
committer | Jérôme Loyet <fat@php.net> | 2011-07-05 01:43:50 +0000 |
commit | efcfbc953e339a265a5ed9747f8a17ea64175e08 (patch) | |
tree | 8f4eff8fa5f42110d5fea9904d8eea7f38b40c35 | |
parent | c4d83a413c0acb19cee64349c24768917f62ada9 (diff) | |
download | php-git-efcfbc953e339a265a5ed9747f8a17ea64175e08.tar.gz |
Fixed memory leak
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | sapi/fpm/fpm/fpm_conf.c | 17 |
2 files changed, 15 insertions, 3 deletions
@@ -31,6 +31,7 @@ PHP NEWS . Implemented FR #54172 (Overriding the pid file location of php-fpm). (fat) . Fixed missing Expires and Cache-Control headers for ping and status pages. (fat) + . Fixed memory leak. (fat) Reported and fixed by Giovanni Giacobbi. - SPL extension: . Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index cc7baea31e..9e52c79449 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -123,6 +123,9 @@ static int fpm_conf_is_dir(char *path) /* {{{ */ } /* }}} */ +/* + * Expands the '$pool' token in a dynamically allocated string + */ static int fpm_conf_expand_pool_name(char **value) { char *token; @@ -130,15 +133,23 @@ static int fpm_conf_expand_pool_name(char **value) { return 0; } - while ((token = strstr(*value, "$pool"))) { + while (*value && (token = strstr(*value, "$pool"))) { char *buf; - char *p1 = *value; char *p2 = token + strlen("$pool"); + + /* If we are not in a pool, we cannot expand this name now */ if (!current_wp || !current_wp->config || !current_wp->config->name) { return -1; } + + /* "aaa$poolbbb" becomes "aaa\0oolbbb" */ token[0] = '\0'; - spprintf(&buf, 0, "%s%s%s", p1, current_wp->config->name, p2); + + /* Build a brand new string with the expanded token */ + spprintf(&buf, 0, "%s%s%s", *value, current_wp->config->name, p2); + + /* Free the previous value and save the new one */ + free(*value); *value = strdup(buf); efree(buf); } |