summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Jacquin <bjacquin@exosec.fr>2012-12-11 15:45:23 +0100
committerBertrand Jacquin <bjacquin@exosec.fr>2012-12-11 15:45:23 +0100
commit8db85864bd850082aa73e8a83181ea2b6f5e7b69 (patch)
treee3eecd7adbf758bec0585e67a056057f2fe125cc
parent[CLEANUP] Indent vv_var_new() with new elm->handler longer than others (diff)
downloadmod_virtualvalue-8db85864bd850082aa73e8a83181ea2b6f5e7b69.tar.gz
[MISC] vv_set(): Add new element to list only if a handler has been
found, this can lead to NULL references.
-rw-r--r--mod_virtualvalue.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/mod_virtualvalue.c b/mod_virtualvalue.c
index 8e357a1..b3acc12 100644
--- a/mod_virtualvalue.c
+++ b/mod_virtualvalue.c
@@ -284,13 +284,6 @@ static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, cha
if (!n)
return NULL;
- if (!c->vars) {
- c->vars = n;
- }
- else {
- vv_var_append (c->vars, n);
- }
-
n->tok = argv[0];
n->argc = argc - 1;
@@ -306,6 +299,12 @@ static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, cha
}
n->argv = (char **)malloc(n->argc * sizeof(char*));
+ if (!c->vars) {
+ c->vars = n;
+ }
+ else {
+ vv_var_append(c->vars, n);
+ }
while (--argc > 0) { /* Or --argc >= 1, We don't need argv[0], as is tok */
n->argv[argc-1] = argv[argc];