From c15fef2fefe119d8b37e2bfab3ef14adac2828b5 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Fri, 21 Jun 2013 17:16:57 -0400 Subject: [PATCH] * #26295: sip: don't crash if transport could not be created --- daemon/src/sip/sipvoiplink.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 9d15e5dc2e..d3039b347f 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -678,14 +678,16 @@ void SIPVoIPLink::sendRegister(Account *a) std::string contact = account->getContactHeader(); pj_str_t pjContact = pj_str((char*) contact.c_str()); - if (account->isStunEnabled()) { - DEBUG("Setting VIA sent-by to %s:%u", account->transport_->local_name.host.ptr, account->transport_->local_name.port); - if (pjsip_regc_set_via_sent_by(regc, &account->transport_->local_name, account->transport_) != PJ_SUCCESS) - throw VoipLinkException("Unable to set the \"sent-by\" field"); - } else if (not received.empty() and received != account->getPublishedAddress()) { - DEBUG("Setting VIA sent-by to %s:%d", received.c_str(), account->getRPort()); - if (pjsip_regc_set_via_sent_by(regc, account->getViaAddr(), account->transport_) != PJ_SUCCESS) - throw VoipLinkException("Unable to set the \"sent-by\" field"); + if (account->transport_) { + if (account->isStunEnabled()) { + DEBUG("Setting VIA sent-by to %s:%u", account->transport_->local_name.host.ptr, account->transport_->local_name.port); + if (pjsip_regc_set_via_sent_by(regc, &account->transport_->local_name, account->transport_) != PJ_SUCCESS) + throw VoipLinkException("Unable to set the \"sent-by\" field"); + } else if (not received.empty() and received != account->getPublishedAddress()) { + DEBUG("Setting VIA sent-by to %s:%d", received.c_str(), account->getRPort()); + if (pjsip_regc_set_via_sent_by(regc, account->getViaAddr(), account->transport_) != PJ_SUCCESS) + throw VoipLinkException("Unable to set the \"sent-by\" field"); + } } if (pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, account->getRegistrationExpire()) != PJ_SUCCESS) -- GitLab