--- channels/chan_sip_orig.sip 2013-12-04 15:52:29.210168641 +0100 +++ channels/chan_sip.c 2013-12-04 15:52:58.707720302 +0100 @@ -12894,16 +12894,20 @@ connected_num = S_COR(caller->connected.id.number.valid, caller->connected.id.number.str, ""); - need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@"); - local_target = alloca(need); - snprintf(local_target, need, "sip:%s@%s", connected_num, p->fromdomain); - + if ( ! ast_strlen_zero(connected_num)) { + need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@"); + local_target = alloca(need); + snprintf(local_target, need, "sip:%s@%s", connected_num, p->fromdomain); + } + ast_xml_escape(S_COR(caller->connected.id.name.valid, - caller->connected.id.name.str, ""), + caller->connected.id.name.str, local_display), local_display, sizeof(local_display)); ast_channel_unlock(caller); caller = ast_channel_unref(caller); + } else { + ast_log(LOG_WARNING, "dialog Notify: Cannot find calling channel, local and remote will be the same\n"); } /* We create a fake call-id which the phone will send back in an INVITE