]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res/res_pjsip: Fix off nominal crash with requests that fail and have a timer 40/1640/1
authorMatt Jordan <mjordan@digium.com>
Mon, 16 Nov 2015 19:56:49 +0000 (13:56 -0600)
committerMatt Jordan <mjordan@digium.com>
Mon, 16 Nov 2015 20:09:55 +0000 (14:09 -0600)
commita83e426e9105882e03f2d84a7ff03436bd76b235
treeab36dbe19cd329765737af8c7b960e9ea61cfa6b
parenta1fcf6f7b28caf8e2f9b808449c86515e2ef90c4
res/res_pjsip: Fix off nominal crash with requests that fail and have a timer

When a request is sent using pjsip_endpt_send_request and fails, a condition
exists where the request wrapper, which is an AO2 object, may be de-ref'd
more times than it should. This occurs when the request's callback is called,
and, in the callback, the timer on the PJSIP heap is cancelled. When that
occurs, the request wrapper's lifetime is decremented. When
pjsip_endpt_send_request fails, we unilaterally decrement the lifetime of
the request wrapper again, even though we've already cancelled the reference
associated with the timer.

This patch checks the return result of pj_timer_heap_cancel_if_active before
removing the reference associated with the timer. We now only decrement it
in this case if a timer is cancelled as a result of the function call.

Change-Id: I21332343a1a019c1117076f9bf2df27be2850102
res/res_pjsip.c