Skip to content

Commit 9620fb7

Browse files
author
Jérôme Loyet
committed
- Dropped restriction of not setting the same value multiple times, the last one holds (giovanni at giacobbi dot net)
1 parent 25fb197 commit 9620fb7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

sapi/fpm/fpm/fpm_conf.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,25 @@ static char *fpm_conf_set_boolean(zval *value, void **config, intptr_t offset) /
195195

196196
static char *fpm_conf_set_string(zval *value, void **config, intptr_t offset) /* {{{ */
197197
{
198-
char *new;
199-
char **old = (char **) ((char *) *config + offset);
200-
if (*old) {
201-
return "it's already been defined. Can't do that twice.";
198+
char **config_val = (char **) ((char *) *config + offset);
199+
200+
if (!config_val) {
201+
return "internal error: NULL value";
202+
}
203+
204+
/* Check if there is a previous value to deallocate */
205+
if (*config_val) {
206+
free(*config_val);
202207
}
203208

204-
new = strdup(Z_STRVAL_P(value));
205-
if (!new) {
209+
*config_val = strdup(Z_STRVAL_P(value));
210+
if (!*config_val) {
206211
return "fpm_conf_set_string(): strdup() failed";
207212
}
208-
if (fpm_conf_expand_pool_name(&new) == -1) {
213+
if (fpm_conf_expand_pool_name(config_val) == -1) {
209214
return "Can't use '$pool' when the pool is not defined";
210215
}
211216

212-
*old = new;
213217
return NULL;
214218
}
215219
/* }}} */
@@ -219,8 +223,9 @@ static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset) /
219223
char *val = Z_STRVAL_P(value);
220224
char *p;
221225

226+
/* we don't use strtol because we don't want to allow negative values */
222227
for (p = val; *p; p++) {
223-
if ( p == val && *p == '-' ) continue;
228+
if (p == val && *p == '-') continue;
224229
if (*p < '0' || *p > '9') {
225230
return "is not a valid number (greater or equal than zero)";
226231
}

0 commit comments

Comments
 (0)