diff --git a/modules/dispatcher/dispatch.c b/modules/dispatcher/dispatch.c index 552ecaae5c..050673ae05 100644 --- a/modules/dispatcher/dispatch.c +++ b/modules/dispatcher/dispatch.c @@ -570,9 +570,16 @@ ds_pvar_param_p ds_get_pvar_param(int id, str uri) int len = ds_pattern_prefix.len + ds_pattern_infix.len + ds_pattern_suffix.len + uri.len + str_id.len; - char buf[len]; /* XXX: check if this works for all compilers */ + char *buf; ds_pvar_param_p param; + param = shm_malloc(sizeof *param + len); + if (!param) { + LM_ERR("no more shm memory\n"); + return NULL; + } + buf = param->buf; + if (ds_pattern_one>DS_PATTERN_NONE) { name.len = 0; name.s = buf; @@ -598,12 +605,6 @@ ds_pvar_param_p ds_get_pvar_param(int id, str uri) name.len += ds_pattern_suffix.len; } - param = shm_malloc(sizeof(ds_pvar_param_t)); - if (!param) { - LM_ERR("no more shm memory\n"); - return NULL; - } - if (!pv_parse_spec(ds_pattern_one>DS_PATTERN_NONE ? &name : &ds_pattern_prefix, ¶m->pvar)) { LM_ERR("cannot parse pattern spec\n"); diff --git a/modules/dispatcher/dispatch.h b/modules/dispatcher/dispatch.h index f470941ac5..b8e0867b30 100644 --- a/modules/dispatcher/dispatch.h +++ b/modules/dispatcher/dispatch.h @@ -107,6 +107,7 @@ typedef struct _ds_pvar_param { pv_spec_t pvar; int value; + char buf[0]; } ds_pvar_param_t, *ds_pvar_param_p;