mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-18 15:49:56 +00:00
Release the allocated channel decreasing the reference counter.
When allocating the channel use ao2_ref(-1) to release it, instead of calling ast_free(). Also avoid freeing structures inside that channel (on error) if they will be released by the channel destructor being called if the reference counter reachs 0. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@200108 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -812,27 +812,20 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
|
|||||||
|
|
||||||
if (!(tmp->sched = sched_context_create())) {
|
if (!(tmp->sched = sched_context_create())) {
|
||||||
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
|
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
|
||||||
ast_free(tmp);
|
return ast_channel_unref(tmp);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ast_string_field_init(tmp, 128))) {
|
if ((ast_string_field_init(tmp, 128))) {
|
||||||
sched_context_destroy(tmp->sched);
|
return ast_channel_unref(tmp);
|
||||||
ast_free(tmp);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cid_name) {
|
if (cid_name) {
|
||||||
if (!(tmp->cid.cid_name = ast_strdup(cid_name))) {
|
if (!(tmp->cid.cid_name = ast_strdup(cid_name))) {
|
||||||
ast_string_field_free_memory(tmp);
|
|
||||||
sched_context_destroy(tmp->sched);
|
|
||||||
return ast_channel_unref(tmp);
|
return ast_channel_unref(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cid_num) {
|
if (cid_num) {
|
||||||
if (!(tmp->cid.cid_num = ast_strdup(cid_num))) {
|
if (!(tmp->cid.cid_num = ast_strdup(cid_num))) {
|
||||||
ast_string_field_free_memory(tmp);
|
|
||||||
sched_context_destroy(tmp->sched);
|
|
||||||
return ast_channel_unref(tmp);
|
return ast_channel_unref(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user