From 38738a7316c944daa2e4968e2c0eaa61af8fd09a Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Wed, 21 Jan 2015 21:57:45 +0000
Subject: [PATCH] res_pjsip_outbound_registration.c: Move unref to a better
 place.

Move an unconditional unref of client_state so it doesn't look like it
could be used after the last ref has destroyed it.
........

Merged revisions 430902 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430903 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 res/res_pjsip_outbound_registration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 167bf7f3d3..2aed231ee7 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -462,8 +462,6 @@ static int handle_client_registration(void *data)
 	pjsip_regc_info info;
 	char server_uri[PJSIP_MAX_URL_SIZE], client_uri[PJSIP_MAX_URL_SIZE];
 
-	ao2_ref(client_state, -1);
-
 	if ((client_state->status == SIP_REGISTRATION_STOPPED) ||
 		(pjsip_regc_register(client_state->client, PJ_FALSE, &tdata) != PJ_SUCCESS)) {
 		return 0;
@@ -512,6 +510,7 @@ static void sip_outbound_registration_timer_cb(pj_timer_heap_t *timer_heap, stru
 		ast_log(LOG_WARNING, "Failed to pass outbound registration to threadpool\n");
 		ao2_ref(client_state, -1);
 	}
+	ao2_ref(client_state, -1);
 
 	entry->id = 0;
 }
-- 
GitLab