svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c
trunk/sapi/fpm/fpm/fpm_conf.c

From: Date: Tue, 05 Jul 2011 01:43:50 +0000
Subject: svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c
trunk/sapi/fpm/fpm/fpm_conf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-65408@lists.php.net to get a copy of this message
fat Tue, 05 Jul 2011 01:43:50 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=312923 Log: Fixed memory leak Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c U php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c U php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-07-05 01:24:10 UTC (rev 312922) +++ php/php-src/branches/PHP_5_3/NEWS 2011-07-05 01:43:50 UTC (rev 312923) @@ -31,6 +31,7 @@ . 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 Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c =================================================================== --- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c 2011-07-05 01:24:10 UTC (rev 312922) +++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c 2011-07-05 01:43:50 UTC (rev 312923) @@ -123,6 +123,9 @@ } /* }}} */ +/* + * Expands the '$pool' token in a dynamically allocated string + */ static int fpm_conf_expand_pool_name(char **value) { char *token; @@ -130,15 +133,23 @@ 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); } Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c =================================================================== --- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c 2011-07-05 01:24:10 UTC (rev 312922) +++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c 2011-07-05 01:43:50 UTC (rev 312923) @@ -123,6 +123,9 @@ } /* }}} */ +/* + * Expands the '$pool' token in a dynamically allocated string + */ static int fpm_conf_expand_pool_name(char **value) { char *token; @@ -130,15 +133,23 @@ 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); } Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c =================================================================== --- php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c 2011-07-05 01:24:10 UTC (rev 312922) +++ php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c 2011-07-05 01:43:50 UTC (rev 312923) @@ -123,6 +123,9 @@ } /* }}} */ +/* + * Expands the '$pool' token in a dynamically allocated string + */ static int fpm_conf_expand_pool_name(char **value) { char *token; @@ -130,15 +133,23 @@ 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); }

« previous php.cvs (#65408) next »