diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 85f9f057aae61b18acde84dbe6a9515fc16e8699..b69bf3f07cd11b1b26743268e57f6260af5db0fd 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -9130,11 +9130,20 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast) CHANNEL_DEADLOCK_AVOIDANCE(ast); /* - * For PRI channels, we must refresh the private pointer because - * the call could move to another B channel while the Asterisk - * channel is unlocked. + * Check to see if the channel is still associated with the same + * private structure. While the Asterisk channel was unlocked + * the following events may have occured: + * + * 1) A masquerade may have associated the channel with another + * technology or private structure. + * + * 2) For PRI calls, call signaling could change the channel + * association to another B channel (private structure). */ - p = ast_channel_tech_pvt(ast); + if (ast_channel_tech_pvt(ast) != p) { + /* The channel is no longer associated. Quit gracefully. */ + return &ast_null_frame; + } } idx = dahdi_get_index(ast, p, 0);