summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Jacquin <bjacquin@exosec.fr>2012-12-11 15:46:55 +0100
committerBertrand Jacquin <bjacquin@exosec.fr>2012-12-11 15:46:55 +0100
commit8ebe3481a80bfa27d38e70d334724bccbe1eb339 (patch)
tree6a5b98b96e9e3903a8fe7c23beb49e4c92b7b90f
parent[MISC] vv_set(): Add new element to list only if a handler has been (diff)
downloadmod_virtualvalue-8ebe3481a80bfa27d38e70d334724bccbe1eb339.tar.gz
[CLEANUP] Eliminate the usage of malloc() in vv_set
-rw-r--r--mod_virtualvalue.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mod_virtualvalue.c b/mod_virtualvalue.c
index b3acc12..f2aa9d6 100644
--- a/mod_virtualvalue.c
+++ b/mod_virtualvalue.c
@@ -285,7 +285,6 @@ static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, cha
return NULL;
n->tok = argv[0];
- n->argc = argc - 1;
for (i = token_tab ; i->tok != NULL ; i++) {
if (strncmp(i->tok, n->tok, i->len) == 0) {
@@ -298,7 +297,6 @@ static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, cha
return apr_pstrcat(cmd->pool, "Invalid Token ", argv[0], NULL);
}
- n->argv = (char **)malloc(n->argc * sizeof(char*));
if (!c->vars) {
c->vars = n;
}
@@ -306,6 +304,10 @@ static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, cha
vv_var_append(c->vars, n);
}
+ /* Insert into n all argv without token already in n->tok */
+ n->argc = argc - 1;
+ n->argv = (char **)apr_palloc(cmd->pool, (n->argc + 1) * sizeof(char*));
+
while (--argc > 0) { /* Or --argc >= 1, We don't need argv[0], as is tok */
n->argv[argc-1] = argv[argc];
}