diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-04-14 11:10:31 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-04-14 11:10:31 +0000 |
commit | dd1a5450ea2888d7246897e84d137aa0e37df35e (patch) | |
tree | 597d85e09c94b9cf157c19b7150e5c8de4c9cd0e /pjsip/src/pjsua-lib/pjsua_pres.c | |
parent | 1828ebd3406cbe2563fe3699599590bf30b69f54 (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/src/pjsua-lib/pjsua_pres.c')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_pres.c | 13 |
1 files changed, 12 insertions, 1 deletions
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); } |