Skip to content

Commit

Permalink
[dialog] fix bad unref leading to dialog leaking
Browse files Browse the repository at this point in the history
When using the dlg_on_timeout to set a new timeout for the dialog, due to the timer related operations (re-inserting in the list), an extra ref cnt happens. If not unref'ed, the dialog will stay (as terminated) forever in memory.

Closes #2788

(cherry picked from commit 4062de4)
  • Loading branch information
bogdan-iancu committed Sep 14, 2022
1 parent 3230fe3 commit f0ff350
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/dialog/dlg_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2318,8 +2318,13 @@ void dlg_ontimeout(struct dlg_tl *tl)
run_dlg_script_route( dlg, dlg->rt_on_timeout);
/* let's see what happened */
if (tl->timeout) {
/* dialog is back on the timelist, inheriting the ref count;
* also replicate an update, if some dlg data changed during
/* dialog is back on the timelist; the set_dlg_timeout()
* performed a fresh insert into timelist (as we previosly removed
* the dialog from it), so a new ref was added -> right now we
* have 2 refs for timerlist, the old one and new one
* -> get rid of one */
unref_dlg(dlg, 1);
/* also replicate an update, if some dlg data changed during
* the execution of the on-timeout route */
if (dialog_repl_cluster && dlg->flags&DLG_FLAG_VP_CHANGED)
replicate_dialog_updated(dlg);
Expand Down

0 comments on commit f0ff350

Please sign in to comment.