diff --git a/plugins/janus_sip.c b/plugins/janus_sip.c index dcc6da0d751..30edbe66f09 100644 --- a/plugins/janus_sip.c +++ b/plugins/janus_sip.c @@ -5479,11 +5479,19 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, if(status == 401) { /* Get scheme/realm from 401 error */ sip_www_authenticate_t const* www_auth = sip->sip_www_authenticate; + if(www_auth == NULL) { + /* No WWW-Authenticate header, give up */ + goto auth_failed; + } scheme = www_auth->au_scheme; realm = msg_params_find(www_auth->au_params, "realm="); } else { /* Get scheme/realm from 407 error, proxy-auth */ sip_proxy_authenticate_t const* proxy_auth = sip->sip_proxy_authenticate; + if(proxy_auth == NULL) { + /* No Proxy-Authenticate header, give up */ + goto auth_failed; + } scheme = proxy_auth->au_scheme; realm = msg_params_find(proxy_auth->au_params, "realm="); } @@ -5517,6 +5525,7 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, NUTAG_AUTH(auth), TAG_END()); } else if(status >= 400) { +auth_failed: /* Authentication failed? */ session->account.registration_status = janus_sip_registration_status_failed; /* Cleanup registration values */