Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 306575) +++ channels/chan_sip.c (working copy) @@ -22332,13 +22332,24 @@ ast_set_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Delay hangup */ - /* For blind transfers, move the call to the new extensions. For attended transfers on multiple - servers - generate an INVITE with Replaces. Either way, let the dial plan decided */ - /* indicate before masquerade so the indication actually makes it to the real channel - when using local channels with MOH passthru */ - ast_indicate(current.chan2, AST_CONTROL_UNHOLD); - res = ast_async_goto(current.chan2, p->refer->refer_to_context, p->refer->refer_to, 1); + { + char refer_to_context[AST_MAX_EXTENSION]; + char refer_to[AST_MAX_EXTENSION]; + /* For blind transfers, move the call to the new extensions. For attended transfers on multiple + servers - generate an INVITE with Replaces. Either way, let the dial plan decided */ + /* indicate before masquerade so the indication actually makes it to the real channel + when using local channels with MOH passthru */ + ast_indicate(current.chan2, AST_CONTROL_UNHOLD); + /* Both are SAFE */ + strcpy(refer_to_context, p->refer->refer_to_context); + strcpy(refer_to, p->refer->refer_to); + + sip_pvt_unlock(p); + res = ast_async_goto(current.chan2, refer_to_context, refer_to, 1); + sip_pvt_lock(p); + } + if (!res) { ast_manager_event_multichan(EVENT_FLAG_CALL, "Transfer", 2, chans, "TransferMethod: SIP\r\n"