Blob Blame History Raw
From: Razvan Crainea <razvan@opensips.org>
Date: Tue, 29 Aug 2017 12:29:13 +0300
Subject: [PATCH] dialog: do not allow callbacks in state DELETED

If these callbacks would have been registered, they will be never ran,
but the free function will still be called. This breaks some modules
(such as acc), which rely the function will be called.

(cherry picked from commit 83669d2caec38823ce79ccd12eec4ed013e2d867)

diff --git a/modules/dialog/dlg_cb.c b/modules/dialog/dlg_cb.c
index 3d7327c79..d1cca0264 100644
--- a/modules/dialog/dlg_cb.c
+++ b/modules/dialog/dlg_cb.c
@@ -127,6 +127,12 @@ int register_dlgcb(struct dlg_cell *dlg, int types, dialog_cb f,
 			return -1;
 		}
 	}
+	/* XXX: do not register callbacks in DELETED state */
+	if (dlg && dlg->state == DLG_STATE_DELETED) {
+		LM_WARN("Cannot register callbacks in DELETED state (type %x)!\n", types);
+		return -1;
+	}
+
 	cb = (struct dlg_callback*)shm_malloc(sizeof(struct dlg_callback));
 	if (cb==0) {
 		LM_ERR("no more shm mem\n");