summaryrefslogtreecommitdiff
path: root/channels/chan_pjsip.c
diff options
context:
space:
mode:
authorScott Griepentrog <scott@griepentrog.com>2015-08-26 14:25:42 -0500
committerScott Griepentrog <sgriepentrog@digium.com>2015-08-26 15:19:20 -0500
commitf1cd6366588c66dce5be66541ceb7f828fde3773 (patch)
tree5e990f45af0c9edfc54f6661289c0e3465c69eff /channels/chan_pjsip.c
parentc01111223f9dbd383a4dd1cf786b63eff214f238 (diff)
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
Diffstat (limited to 'channels/chan_pjsip.c')
-rw-r--r--channels/chan_pjsip.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index bb79e84a5..49995a2f8 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1762,9 +1762,17 @@ static int hangup(void *data)
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;