[Asterisk-code-review] chan pjsip: segfault on hangup (asterisk[13])

Alexei Gradinari asteriskteam at digium.com
Thu Oct 13 15:12:23 CDT 2016


Alexei Gradinari has uploaded a new change for review.

  https://gerrit.asterisk.org/4085

Change subject: chan_pjsip: segfault on hangup
......................................................................

chan_pjsip: segfault on hangup

The chan_pjsip puts a function 'hangup' into a serializer on hang up.
When this task is popped from the serializer an ast_channel
could be destroyed.
Need to check the ast_channel and channel's session and pvt.

ASTERISK-26467 #close

Change-Id: I702faac011819b37a430b710468782fc16154cc9
---
M channels/chan_pjsip.c
1 file changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/85/4085/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 2354511..d107f9a 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1847,14 +1847,21 @@
 {
 	struct hangup_data *h_data = data;
 	struct ast_channel *ast = h_data->chan;
-	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
-	struct chan_pjsip_pvt *pvt = channel->pvt;
-	struct ast_sip_session *session = channel->session;
+	struct ast_sip_channel_pvt *channel;
 	int cause = h_data->cause;
 
-	ast_sip_session_terminate(session, cause);
-	clear_session_and_channel(session, ast, pvt);
-	ao2_cleanup(channel);
+	if (ast) {
+		channel = ast_channel_tech_pvt(ast);
+		if (channel) {
+			if (channel->session) {
+				ast_sip_session_terminate(channel->session, cause);
+				if (channel->pvt) {
+					clear_session_and_channel(channel->session, ast, channel->pvt);
+				}
+			}
+			ao2_cleanup(channel);
+		}
+	}
 	ao2_cleanup(h_data);
 
 	return 0;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I702faac011819b37a430b710468782fc16154cc9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>



More information about the asterisk-code-review mailing list