Index: channels/chan_pjsip.c =================================================================== --- channels/chan_pjsip.c (revision 430609) +++ channels/chan_pjsip.c (working copy) @@ -2024,6 +2024,24 @@ return 0; } + if (session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED) { + /* Weird case. We've received a reinvite but we don't have a channel. The most + * typical case for this happening is that a blind transfer fails, and so the + * transferer attempts to reinvite himself back into the call. We already got + * rid of that channel, and the other side of the call is unrecoverable. + * + * We treat this as a failure, so our best bet is to just hang this call + * up and not create a new channel. + */ + pjsip_tx_data *tdata; + pjsip_inv_end_session(session->inv_session, 400, NULL, &tdata); + /* Sending a request because the inv_session code has already sent a 200 OK. We're sending + * a BYE here. + */ + ast_sip_session_send_request(session, tdata); + return -1; + } + datastore = ast_sip_session_alloc_datastore(&transport_info, "transport_info"); if (!datastore) { return -1;