]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Ensure that the stored CDR reference is still valid after the bridge before
authorRussell Bryant <russell@russellbryant.com>
Tue, 9 Sep 2008 15:40:24 +0000 (15:40 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 9 Sep 2008 15:40:24 +0000 (15:40 +0000)
poking at it.  Also, keep the channel locked while messing with this CDR.

(fixes crashes reported in issue #13409)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@142063 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_features.c

index 24b0a46b246654a925c30f9cdcb7d52b2870678f..475c7711c184decaee8f644e82f70b22a062d114 100644 (file)
@@ -1678,6 +1678,22 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
                        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 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
                                }
                        }
                        ast_cdr_specialized_reset(orig_peer_cdr,0);
+                       ast_channel_unlock(peer);
                }
        }
        return res;