[asterisk-commits] Chaos: make hangup NULL tolerant (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 27 14:53:46 CDT 2015


Mark Michelson has submitted this change and it was merged.

Change subject: Chaos: make hangup NULL tolerant
......................................................................


Chaos: make hangup NULL tolerant

In chan_pjsip_new, if allocation of the pvt
structure fails, ast_hangup is called.  But
it was written to assume pvt was valid, and
this change corrects that.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87
---
M channels/chan_pjsip.c
1 file changed, 11 insertions(+), 3 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index d3ba0a2..9603f05 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1811,9 +1811,17 @@
 static int chan_pjsip_hangup(struct ast_channel *ast)
 {
 	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
-	struct chan_pjsip_pvt *pvt = channel->pvt;
-	int cause = hangup_cause2sip(ast_channel_hangupcause(channel->session->channel));
-	struct hangup_data *h_data = hangup_data_alloc(cause, ast);
+	struct chan_pjsip_pvt *pvt;
+	int cause;
+	struct hangup_data *h_data;
+
+	if (!channel || !channel->session) {
+		return -1;
+	}
+
+	pvt = channel->pvt;
+	cause = hangup_cause2sip(ast_channel_hangupcause(channel->session->channel));
+	h_data = hangup_data_alloc(cause, ast);
 
 	if (!h_data) {
 		goto failure;

-- 
To view, visit https://gerrit.asterisk.org/1145
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list