<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8175">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr.c: Fix runtime leak of CDR records.<br><br>Need to remove all CDR's listed by a CDR object from the active_cdrs_all<br>container including the root/master record.<br><br>ASTERISK-27656<br><br>Change-Id: I48b4970663fea98baa262593d2204ef304aaf80e<br>---<br>M main/cdr.c<br>1 file changed, 10 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/75/8175/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/cdr.c b/main/cdr.c<br>index 90371a4..3e02c3e 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -371,7 +371,7 @@<br> /*! \brief A container of the active master CDRs indexed by Party A channel uniqueid */<br> static struct ao2_container *active_cdrs_master;<br> <br>-/*! \brief A container of all active CDRs indexed by Party B channel name */<br>+/*! \brief A container of all active CDRs with a Party B indexed by Party B channel name */<br> static struct ao2_container *active_cdrs_all;<br> <br> /*! \brief Message router for stasis messages regarding channel state */<br>@@ -971,13 +971,21 @@<br> <br>     ast_assert(cdr->is_root);<br> <br>+      /* Hold a ref to the root CDR to ensure the list members don't go away on us. */<br>+ ao2_ref(cdr, +1);<br>     ao2_lock(active_cdrs_all);<br>-   for (cur = cdr->next; cur; cur = next) {<br>+  for (cur = cdr; cur; cur = next) {<br>            next = cur->next;<br>          ao2_unlink_flags(active_cdrs_all, cur, OBJ_NOLOCK);<br>+          /*<br>+            * It is safe to still use cur after unlinking because the<br>+            * root CDR holds a ref to all the CDRs in the list and we<br>+            * have a ref to the root CDR.<br>+                */<br>           ast_string_field_set(cur, party_b_name, "");<br>        }<br>     ao2_unlock(active_cdrs_all);<br>+ ao2_ref(cdr, -1);<br> }<br> <br> /*!<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8175">change 8175</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8175"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I48b4970663fea98baa262593d2204ef304aaf80e </div>
<div style="display:none"> Gerrit-Change-Number: 8175 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>