res_pjsip_outbound_registration: Fix double unref on error return.
authorJoshua Colp <jcolp@digium.com>
Thu, 30 Apr 2015 11:04:34 +0000 (08:04 -0300)
committerJoshua Colp <jcolp@digium.com>
Thu, 30 Apr 2015 12:25:26 +0000 (07:25 -0500)
commit80aa9aee5df2dd41ab5a59f6437d43642e184e45
treee87d41d7df24c371cb7b045547120180b871a423
parent7fe923d20b7e1b2b27b10a1fb4fa627da7d95149
res_pjsip_outbound_registration: Fix double unref on error return.

When the PJSIP pjsip_regc_send function is invoked and an error
status returned the caller currently decrements the reference count
of the client state that it just incremented, assuming the
registration callback would not have been invoked. In practice
this is not correct. If the failure happens after the transaction
has been set up the callback will still be invoked. This will
cause the reference count to be incorrectly decremented twice, once
by the registration callback and second by the caller of
pjsip_regc_send.

This change makes it so that whether the callback is invoked or
not is known by the caller of pjsip_regc_send. Depending on
this it can know whether it is responsible for decrementing the
reference count of the client state or not.

ASTERISK-25037 #close
Reported by: Joshua Colp

Change-Id: I749dc12f3a22115c49c5d7d95ff42a5fa45319de
res/res_pjsip_outbound_registration.c