<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7740">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr: Missing NULL check and unlock.<br><br>* handle_dial_message: Missing a check for NULL peer.<br>* cdr_generic_register: Missing unlock on allocation failure.<br><br>cdr_generic_register is fixed by reordering so the new structure is<br>allocated and initialized before locking the list.<br><br>Change-Id: I5799b99270d1a7a716a555c31ac85f4b00ce8686<br>---<br>M main/cdr.c<br>1 file changed, 25 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/40/7740/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/cdr.c b/main/cdr.c<br>index 0b571fe..df5ce54 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -2094,7 +2094,12 @@<br> if (!peer && !caller) {<br> return;<br> }<br>- if (filter_channel_snapshot(peer) || (caller && filter_channel_snapshot(caller))) {<br>+<br>+ if (peer && filter_channel_snapshot(peer)) {<br>+ return;<br>+ }<br>+<br>+ if (caller && filter_channel_snapshot(caller)) {<br> return;<br> }<br> <br>@@ -2868,32 +2873,39 @@<br> <br> int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)<br> {<br>- struct cdr_beitem *i = NULL;<br>+ struct cdr_beitem *i;<br>+ struct cdr_beitem *cur;<br> <br>- if (!name)<br>+ if (!name) {<br> return -1;<br>+ }<br> <br> if (!be) {<br> ast_log(LOG_WARNING, "CDR engine '%s' lacks backend\n", name);<br>+<br> return -1;<br> }<br> <br>- AST_RWLIST_WRLOCK(&be_list);<br>- AST_RWLIST_TRAVERSE(&be_list, i, list) {<br>- if (!strcasecmp(name, i->name)) {<br>- ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);<br>- AST_RWLIST_UNLOCK(&be_list);<br>- return -1;<br>- }<br>- }<br>-<br>- if (!(i = ast_calloc(1, sizeof(*i))))<br>+ i = ast_calloc(1, sizeof(*i));<br>+ if (!i) {<br> return -1;<br>+ }<br> <br> i->be = be;<br> ast_copy_string(i->name, name, sizeof(i->name));<br> ast_copy_string(i->desc, desc, sizeof(i->desc));<br> <br>+ AST_RWLIST_WRLOCK(&be_list);<br>+ AST_RWLIST_TRAVERSE(&be_list, cur, list) {<br>+ if (!strcasecmp(name, cur->name)) {<br>+ ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);<br>+ AST_RWLIST_UNLOCK(&be_list);<br>+ ast_free(i);<br>+<br>+ return -1;<br>+ }<br>+ }<br>+<br> AST_RWLIST_INSERT_HEAD(&be_list, i, list);<br> AST_RWLIST_UNLOCK(&be_list);<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7740">change 7740</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/7740"/><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: I5799b99270d1a7a716a555c31ac85f4b00ce8686 </div>
<div style="display:none"> Gerrit-Change-Number: 7740 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>