Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -2291,14 +2291,12 @@ int pv_set_dlg_deldelay(struct sip_msg *msg, pv_param_t *param,


#define DLG_CTX_JSON_BUFF_SIZE 32768
#define DEC_AND_CHECK_LEN(_curr,_size) \
do { \
_curr-=_size; \
if (_curr < 0) { \
LM_ERR("No more buf size \n"); \
return NULL; \
} \
} while(0) \
#define DEC_AND_CHECK_LEN(_curr, _size) \
do { \
(_curr) -= (_size); \
if ((_curr) < 0) \
goto buffer_exhausted; \
} while (0)

static char *dlg_get_json_out(struct dlg_cell *dlg,int ctx,int *out_len)
{
Expand All @@ -2307,6 +2305,7 @@ static char *dlg_get_json_out(struct dlg_cell *dlg,int ctx,int *out_len)
struct dlg_val* dv;
char *p;
int i,j,k,len;
int vals_locked = 0;
int intlen;
char *intbuf;
str flag_list;
Expand Down Expand Up @@ -2390,6 +2389,7 @@ static char *dlg_get_json_out(struct dlg_cell *dlg,int ctx,int *out_len)
*p++=']';

lock_start_read(dlg->vals_lock);
vals_locked = 1;

if (ctx && dlg->vals) {
char *it, *end;
Expand Down Expand Up @@ -2470,6 +2470,7 @@ static char *dlg_get_json_out(struct dlg_cell *dlg,int ctx,int *out_len)
}

lock_stop_read(dlg->vals_lock);
vals_locked = 0;

if (ctx && dlg->profile_links) {
memcpy(p,",\"profiles\":{",13);
Expand Down Expand Up @@ -2537,6 +2538,12 @@ static char *dlg_get_json_out(struct dlg_cell *dlg,int ctx,int *out_len)

*out_len = (int)(p-dlg_info);
return dlg_info;

buffer_exhausted:
if (vals_locked)
lock_stop_read(dlg->vals_lock);
LM_ERR("No more buf size \n");
return NULL;
}

int pv_get_dlg_json(struct sip_msg *msg, pv_param_t *param,
Expand Down
5 changes: 3 additions & 2 deletions modules/dialog/dlg_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,11 +1591,11 @@ static void dlg_onreq_out(struct cell* t, int type, struct tmcb_params *ps)
msg->len=buffer.len;

if (parse_msg(buffer.s,buffer.len, msg) != 0)
goto out_free;
goto out_free_unlocked;

if (msg->REQ_METHOD != METHOD_INVITE) {
LM_DBG("skipping method %d\n", msg->REQ_METHOD);
goto out_free;
goto out_free_unlocked;
}

/*
Expand Down Expand Up @@ -1639,6 +1639,7 @@ static void dlg_onreq_out(struct cell* t, int type, struct tmcb_params *ps)

out_free:
dlg_unlock_dlg(dlg);
out_free_unlocked:
free_sip_msg(msg);
pkg_free(msg);
}
Expand Down
20 changes: 15 additions & 5 deletions modules/dialog/dlg_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,18 +1560,26 @@ static inline int internal_mi_print_dlg(mi_item_t *dialog_obj,

} else if (dv->type == DLG_VAL_TYPE_BOOL) {
values_item = add_mi_object(values_arr, NULL, 0);
if (!values_item)
if (!values_item) {
lock_stop_read(dlg->vals_lock);
goto error;
}
if (add_mi_bool(values_item,dv->name.s,dv->name.len,
dv->val.n) < 0)
dv->val.n) < 0) {
lock_stop_read(dlg->vals_lock);
goto error;
}
} else {
values_item = add_mi_object(values_arr, NULL, 0);
if (!values_item)
if (!values_item) {
lock_stop_read(dlg->vals_lock);
goto error;
}
if (add_mi_number(values_item,dv->name.s,dv->name.len,
dv->val.n) < 0)
dv->val.n) < 0) {
lock_stop_read(dlg->vals_lock);
goto error;
}
}
}
}
Expand Down Expand Up @@ -1721,8 +1729,10 @@ static mi_response_t *mi_match_print_dlg(int with_context,
}

resp = init_mi_result_object(&resp_obj);
if (!resp)
if (!resp) {
dlg_unlock(d_table, d_entry);
return NULL;
}

dialog_obj = add_mi_object(resp_obj, MI_SSTR("Dialog"));
if (!dialog_obj)
Expand Down
6 changes: 5 additions & 1 deletion modules/dialog/dlg_vals.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,12 @@ int check_dlg_value(struct sip_msg *msg, struct dlg_cell *dlg, str *name,
break;
} else { /* DLG_VAL_TYPE_INT */
LM_DBG("var found with val <%d>!\n",dv->val.n);
if (pval.ri == dv->val.n)
if (pval.ri == dv->val.n) {
if (lock_vals)
lock_stop_read(dlg->vals_lock);
LM_DBG("var found!\n");
return 0;
}
}
}
}
Expand Down