aboutsummaryrefslogtreecommitdiffstats
path: root/main/channel.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-04-10 16:06:22 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-04-10 16:06:22 +0000
commit37f2471e2ba66cf3932a8a80f605cc1ee1767db5 (patch)
tree6fe1e7cb6fd80d9498858f1be7eed65431f39956 /main/channel.c
parentcce40f89b4a081419a3b139f9969a73784333a84 (diff)
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: http://svn.digium.com/svn/asterisk/trunk@187680 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/main/channel.c b/main/channel.c
index 0c0c1c525..ed88f53f4 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