mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 08:13:22 +00:00
Don't let ast_channel_alloc fail if explicitly passed NULL cid_name or cid_number.
This also fixes a small memory leak. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@187680 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -796,11 +796,22 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(tmp->cid.cid_name = ast_strdup(cid_name)) || !(tmp->cid.cid_num = ast_strdup(cid_num))) {
|
if (cid_name) {
|
||||||
ast_string_field_free_memory(tmp);
|
if (!(tmp->cid.cid_name = ast_strdup(cid_name))) {
|
||||||
sched_context_destroy(tmp->sched);
|
ast_string_field_free_memory(tmp);
|
||||||
ast_free(tmp);
|
sched_context_destroy(tmp->sched);
|
||||||
return NULL;
|
ast_free(tmp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_EPOLL
|
#ifdef HAVE_EPOLL
|
||||||
|
Reference in New Issue
Block a user