diff --git a/main/channel.c b/main/channel.c index 3dcd380fa00f5328a33da7969615932276a0391b..d877fc526eab29fddb0f7aee0a4d5387beeaf93f 100644 --- a/main/channel.c +++ b/main/channel.c @@ -826,17 +826,14 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char if (!(tmp->cid.cid_name = ast_strdup(cid_name))) { ast_string_field_free_memory(tmp); sched_context_destroy(tmp->sched); - ast_free(tmp); - return NULL; + return ast_channel_unref(tmp); } } if (cid_num) { if (!(tmp->cid.cid_num = ast_strdup(cid_num))) { ast_string_field_free_memory(tmp); sched_context_destroy(tmp->sched); - ast_free(tmp->cid.cid_name); - ast_free(tmp); - return NULL; + return ast_channel_unref(tmp); } }