[Asterisk-code-review] Chaos: make hangup NULL tolerant (asterisk[13])

Mark Michelson asteriskteam at digium.com
Thu Aug 27 14:53:42 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 bb79e84..49995a2 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1762,9 +1762,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/1146
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
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-code-review mailing list