diff --git a/main/channel.c b/main/channel.c index 0c0c1c525a..ed88f53f45 100644 --- a/main/channel.c +++ b/main/channel.c @@ -796,11 +796,22 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_ return NULL; } - if (!(tmp->cid.cid_name = ast_strdup(cid_name)) || !(tmp->cid.cid_num = ast_strdup(cid_num))) { - ast_string_field_free_memory(tmp); - sched_context_destroy(tmp->sched); - ast_free(tmp); - return NULL; + if (cid_name) { + 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; + } + } + 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