From 9b2b83d6deb66c9f2b600a932f2dc4dc2ec71f0f Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 12 Aug 2014 12:12:49 +0000 Subject: Misc (re #1751): Remove reference to PJSUA2 Call instance from PJSUA library in PJSUA2 Call destructor regardless the PJSUA state to avoid crash caused by accessing dangling pointer of the Call instance (thanks Thomas Steinacher for the report). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4885 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua2/call.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pjsip/src/pjsua2/call.cpp b/pjsip/src/pjsua2/call.cpp index b196d5d4..1e4e72f3 100644 --- a/pjsip/src/pjsua2/call.cpp +++ b/pjsip/src/pjsua2/call.cpp @@ -379,16 +379,17 @@ Call::Call(Account& account, int call_id) Call::~Call() { - /** + /* Remove reference to this instance from PJSUA library */ + if (id != PJSUA_INVALID_ID) + pjsua_call_set_user_data(id, NULL); + + /* * If this instance is deleted, also hangup the corresponding call in * PJSUA library. */ - if (id != PJSUA_INVALID_ID && pjsua_get_state() < PJSUA_STATE_CLOSING) { - pjsua_call_set_user_data(id, NULL); - if (isActive()) { - CallOpParam prm; - hangup(prm); - } + if (pjsua_get_state() < PJSUA_STATE_CLOSING && isActive()) { + CallOpParam prm; + hangup(prm); } } -- cgit v1.2.3