diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c index add899cdbfe..56ef5a473ac 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c @@ -1478,7 +1478,7 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg, "socket", dlg->bind_addr[DLG_CALLEE_LEG] ? &dlg->bind_addr[DLG_CALLEE_LEG]->sock_str : &empty_str); if (rpc->struct_add(h, "[", "profiles", &sh) < 0) goto error; - for (pl = dlg->profile_links ; pl ; pl=pl->next) { + for (pl = dlg->profile_links ; pl && (dlg->statenext) { if (pl->profile->has_value) { rpc->array_add(sh, "{", &ssh); rpc->struct_add(ssh, "S", pl->profile->name.s, &pl->hash_linker.value); @@ -1488,7 +1488,7 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg, } if (rpc->struct_add(h, "[", "variables", &sh) < 0) goto error; - for(var=dlg->vars ; var ; var=var->next) { + for(var=dlg->vars ; var && (dlg->statenext) { rpc->array_add(sh, "{", &ssh); rpc->struct_add(ssh, "S", var->key.s, &var->value); }