summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-04-14 11:10:31 +0000
committerBenny Prijono <bennylp@teluu.com>2009-04-14 11:10:31 +0000
commitdd1a5450ea2888d7246897e84d137aa0e37df35e (patch)
tree597d85e09c94b9cf157c19b7150e5c8de4c9cd0e /pjsip
parent1828ebd3406cbe2563fe3699599590bf30b69f54 (diff)
Ticket #786: Crash when UAC invite or subscribe session initialization fails (thanks Rostislav Molodyko for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2593 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c16
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c13
2 files changed, 24 insertions, 5 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 87dcfdea..2531cd11 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -467,6 +467,11 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
return status;
}
+ /* Increment the dialog's lock otherwise when invite session creation
+ * fails the dialog will be destroyed prematurely.
+ */
+ pjsip_dlg_inc_lock(dlg);
+
/* Calculate call's secure level */
call->secure_level = get_secure_level(acc_id, dest_uri);
@@ -557,11 +562,10 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
pjsua_perror(THIS_FILE, "Unable to send initial INVITE request",
status);
- /* Upon failure to send first request, both dialog and invite
+ /* Upon failure to send first request, the invite
* session would have been cleared.
*/
inv = NULL;
- dlg = NULL;
goto on_error;
}
@@ -570,6 +574,7 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
if (p_call_id)
*p_call_id = call_id;
+ pjsip_dlg_dec_lock(dlg);
pj_pool_release(tmp_pool);
PJSUA_UNLOCK();
@@ -577,10 +582,13 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
on_error:
+ if (dlg) {
+ /* This may destroy the dialog */
+ pjsip_dlg_dec_lock(dlg);
+ }
+
if (inv != NULL) {
pjsip_inv_terminate(inv, PJSIP_SC_OK, PJ_FALSE);
- } else if (dlg) {
- pjsip_dlg_terminate(dlg);
}
if (call_id != -1) {
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index c0461bd4..2eb78230 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -1442,13 +1442,21 @@ static void subscribe_buddy_presence(unsigned index)
return;
}
+ /* Increment the dialog's lock otherwise when presence session creation
+ * fails the dialog will be destroyed prematurely.
+ */
+ pjsip_dlg_inc_lock(buddy->dlg);
+
status = pjsip_pres_create_uac( buddy->dlg, &pres_callback,
PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub);
if (status != PJ_SUCCESS) {
pjsua_var.buddy[index].sub = NULL;
pjsua_perror(THIS_FILE, "Unable to create presence client",
status);
- pjsip_dlg_terminate(buddy->dlg);
+ /* This should destroy the dialog since there's no session
+ * referencing it
+ */
+ pjsip_dlg_dec_lock(buddy->dlg);
if (tmp_pool) pj_pool_release(tmp_pool);
return;
}
@@ -1481,6 +1489,7 @@ static void subscribe_buddy_presence(unsigned index)
status = pjsip_pres_initiate(buddy->sub, -1, &tdata);
if (status != PJ_SUCCESS) {
+ pjsip_dlg_dec_lock(buddy->dlg);
if (buddy->sub) {
pjsip_pres_terminate(buddy->sub, PJ_FALSE);
}
@@ -1495,6 +1504,7 @@ static void subscribe_buddy_presence(unsigned index)
status = pjsip_pres_send_request(buddy->sub, tdata);
if (status != PJ_SUCCESS) {
+ pjsip_dlg_dec_lock(buddy->dlg);
if (buddy->sub) {
pjsip_pres_terminate(buddy->sub, PJ_FALSE);
}
@@ -1505,6 +1515,7 @@ static void subscribe_buddy_presence(unsigned index)
return;
}
+ pjsip_dlg_dec_lock(buddy->dlg);
if (tmp_pool) pj_pool_release(tmp_pool);
}