From: Mark Michelson Date: Wed, 10 Jun 2009 18:58:12 +0000 (+0000) Subject: Use ast_channel_unref to instead of ast_free on a newly created channel. X-Git-Tag: 11.0.0-beta1~4708 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=554456f0fc9e4bdcfd6c7f8ef14e12ec103cdd54;p=thirdparty%2Fasterisk.git Use ast_channel_unref to instead of ast_free on a newly created channel. Also I removed an unnecessary free of a cid_name. This will be freed properly in the channel destructor. Reported by mnicholson in #asterisk-dev. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@199923 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/channel.c b/main/channel.c index 3dcd380fa0..d877fc526e 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); } }