aboutsummaryrefslogtreecommitdiffstats
path: root/modules/lookup_multi.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lookup_multi.c')
-rw-r--r--modules/lookup_multi.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
index 4fcbf6d..062e4d7 100644
--- a/modules/lookup_multi.c
+++ b/modules/lookup_multi.c
@@ -53,6 +53,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char * const *argv,
if ( !(*context = ctxt = malloc(sizeof(struct lookup_context))) )
goto nomem;
+ memset(ctxt, 0, sizeof(struct lookup_context));
if ( argc < 1 ) {
syslog(LOG_CRIT, MODPREFIX "No map list");
@@ -65,20 +66,20 @@ int lookup_init(const char *my_mapfmt, int argc, const char * const *argv,
}
if ( !(ctxt->m = malloc(ctxt->n*sizeof(struct module_info))) ||
- !(ctxt->argl = malloc((argc+1)*sizeof(const char **))) )
+ !(ctxt->argl = malloc((argc+1)*sizeof(const char *))) )
goto nomem;
+ memset(ctxt->m, 0, ctxt->n*sizeof(struct module_info));
- memcpy(ctxt->argl, argv, (argc+1)*sizeof(const char **));
+ memcpy(ctxt->argl, argv, (argc+1)*sizeof(const char *));
- for ( i = j = an = 0 ; argv[an] ; an++ ) {
- if ( j == 0 )
+ for ( i = j = an = 0 ; ctxt->argl[an] ; an++ ) {
+ if ( ctxt->m[i].argc == 0 )
ctxt->m[i].argv = &ctxt->argl[an];
if ( !strcmp(ctxt->argl[an], "--") ) {
ctxt->argl[an] = NULL;
- i++; j = 0;
+ i++;
} else {
ctxt->m[i].argc++;
- j++;
}
}
@@ -96,7 +97,8 @@ int lookup_init(const char *my_mapfmt, int argc, const char * const *argv,
if ( !(ctxt->m[i].mod = open_lookup(map, MODPREFIX,
mapfmt ? mapfmt : my_mapfmt,
- ctxt->m[i].argc, ctxt->m[i].argv)) )
+ ctxt->m[i].argc - 1,
+ ctxt->m[i].argv + 1)) )
return 1;
}