Skip to content

Commit 02de797

Browse files
committed
[dialog] fixed potential double-free upon delayed delete
If the dialog struct is removed from the timer list (and under processing by the timer), do not attempt to free it here, rather leave it alone, it will be freed by the timer (cherry picked from commit f5f11af)
1 parent e6f2c17 commit 02de797

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

modules/dialog/dlg_hash.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,14 @@ void destroy_dlg(struct dlg_cell *dlg);
337337
if ((_dlg)->ref<=0) { \
338338
/* dlg good to be destried, but be sure it went first
339339
* via the delete timer */ \
340-
if ((dlg_del_delay==0 && (_dlg)->del_delay==0) || \
341-
insert_attempt_dlg_del_timer(&_dlg->del_tl, \
342-
(_dlg)->del_delay?(_dlg)->del_delay:dlg_del_delay)==-2) {\
340+
if ((dlg_del_delay==0 && (_dlg)->del_delay==0)) { \
343341
/* no delay on del or not in del timer anymore -> destroy */ \
344-
LM_DBG("Destroying dialog %p\n",_dlg); \
342+
LM_DBG("Destroying dialog %p due to unref\n",_dlg); \
345343
unlink_unsafe_dlg( _d_entry, _dlg);\
346344
destroy_dlg(_dlg);\
347-
} /* else, either still in timer (-1), either
348-
* inserted now in del timer (0) -> nothing to do*/ \
345+
} else \
346+
insert_attempt_dlg_del_timer(&_dlg->del_tl, \
347+
(_dlg)->del_delay?(_dlg)->del_delay:dlg_del_delay); \
349348
}\
350349
}while(0)
351350

0 commit comments

Comments
 (0)