Merge "cdr: Missing NULL check and unlock."

pull/9/head
Jenkins2 8 years ago committed by Gerrit Code Review
commit 50cf373be5

@ -2097,7 +2097,12 @@ static void handle_dial_message(void *data, struct stasis_subscription *sub, str
if (!peer && !caller) {
return;
}
if (filter_channel_snapshot(peer) || (caller && filter_channel_snapshot(caller))) {
if (peer && filter_channel_snapshot(peer)) {
return;
}
if (caller && filter_channel_snapshot(caller)) {
return;
}
@ -2871,32 +2876,39 @@ int ast_cdr_backend_unsuspend(const char *name)
static int cdr_generic_register(struct be_list *generic_list, const char *name, const char *desc, ast_cdrbe be)
{
struct cdr_beitem *i = NULL;
struct cdr_beitem *i;
struct cdr_beitem *cur;
if (!name)
if (!name) {
return -1;
}
if (!be) {
ast_log(LOG_WARNING, "CDR engine '%s' lacks backend\n", name);
return -1;
}
i = ast_calloc(1, sizeof(*i));
if (!i) {
return -1;
}
i->be = be;
ast_copy_string(i->name, name, sizeof(i->name));
ast_copy_string(i->desc, desc, sizeof(i->desc));
AST_RWLIST_WRLOCK(generic_list);
AST_RWLIST_TRAVERSE(generic_list, i, list) {
if (!strcasecmp(name, i->name)) {
AST_RWLIST_TRAVERSE(generic_list, cur, list) {
if (!strcasecmp(name, cur->name)) {
ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);
AST_RWLIST_UNLOCK(generic_list);
ast_free(i);
return -1;
}
}
if (!(i = ast_calloc(1, sizeof(*i))))
return -1;
i->be = be;
ast_copy_string(i->name, name, sizeof(i->name));
ast_copy_string(i->desc, desc, sizeof(i->desc));
AST_RWLIST_INSERT_HEAD(generic_list, i, list);
AST_RWLIST_UNLOCK(generic_list);

Loading…
Cancel
Save