From 7bc99b0135072ccbcbc7a18fe3fb9900585ca430 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Mon, 31 Mar 2003 15:56:00 +0000 Subject: [PATCH] Fix potential segfault in chan_sip git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@727 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 882d3dffb3..186fa42fb0 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -362,14 +362,26 @@ static int retrans_pkt(void *data) ast_queue_hangup(pkt->owner->owner, 1); } else { /* If no owner, destroy now */ + ast_pthread_mutex_unlock(&pkt->owner->lock); sip_destroy(pkt->owner); + pkt = NULL; } } } else { /* Don't bother retransmitting. It's about to be killed anyway */ pkt->retransid = -1; + if (pkt->owner->owner) { + /* XXX Potential deadlocK?? XXX */ + ast_queue_hangup(pkt->owner->owner, 1); + } else { + /* If no owner, destroy now */ + ast_pthread_mutex_unlock(&pkt->owner->lock); + sip_destroy(pkt->owner); + pkt=NULL; + } } - ast_pthread_mutex_unlock(&pkt->owner->lock); + if (pkt) + ast_pthread_mutex_unlock(&pkt->owner->lock); return res; } @@ -2179,7 +2191,7 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth) char addr[80]; struct sip_pvt *p; /* exit if we are already in process with this registrar ?*/ - if ( (auth==NULL && r->regstate==REG_STATE_REGSENT) || r->regstate==REG_STATE_AUTHSENT) { + if ( r == NULL || (auth==NULL && r->regstate==REG_STATE_REGSENT) || r->regstate==REG_STATE_AUTHSENT) { ast_log(LOG_NOTICE, "Strange, trying to register when registration already pending\n"); return 0; }