Index: res/res_features.c =================================================================== --- res/res_features.c (revision 142004) +++ res/res_features.c (working copy) @@ -1678,6 +1678,22 @@ ast_cdr_specialized_reset(chan->cdr,0); } if (peer->cdr) { + struct ast_cdr *cur; + + ast_channel_lock(peer); + for (cur = peer->cdr; cur; cur = cur->next) { + if (cur == orig_peer_cdr) { + break; + } + } + + if (!cur) { + /* orig_peer_cdr is gone, probably because of a masquerade + * during the bridge. */ + ast_channel_unlock(peer); + return res; + } + /* before resetting the peer cdr, throw a copy of it to the backend, just in case the cdr.conf file is calling for unanswered CDR's. */ @@ -1694,6 +1710,7 @@ } } ast_cdr_specialized_reset(orig_peer_cdr,0); + ast_channel_unlock(peer); } } return res;