mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-09 19:38:22 +00:00
* Fix error path resouce leak in local_request().
* Restructure local_request() to reduce indentation. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@364840 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1159,20 +1159,26 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
|
|||||||
/*! \brief Part of PBX interface */
|
/*! \brief Part of PBX interface */
|
||||||
static struct ast_channel *local_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
|
static struct ast_channel *local_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
|
||||||
{
|
{
|
||||||
struct local_pvt *p = NULL;
|
struct local_pvt *p;
|
||||||
struct ast_channel *chan = NULL;
|
struct ast_channel *chan;
|
||||||
|
|
||||||
/* Allocate a new private structure and then Asterisk channel */
|
/* Allocate a new private structure and then Asterisk channels */
|
||||||
if ((p = local_alloc(data, format))) {
|
p = local_alloc(data, format);
|
||||||
if (!(chan = local_new(p, AST_STATE_DOWN, requestor ? requestor->linkedid : NULL))) {
|
if (!p) {
|
||||||
ao2_unlink(locals, p);
|
return NULL;
|
||||||
}
|
}
|
||||||
if (chan && ast_channel_cc_params_init(chan, requestor ? ast_channel_get_cc_config_params((struct ast_channel *)requestor) : NULL)) {
|
chan = local_new(p, AST_STATE_DOWN, requestor ? requestor->linkedid : NULL);
|
||||||
chan = ast_channel_release(chan);
|
if (!chan) {
|
||||||
ao2_unlink(locals, p);
|
ao2_unlink(locals, p);
|
||||||
|
} else if (ast_channel_cc_params_init(chan, requestor ? ast_channel_get_cc_config_params((struct ast_channel *)requestor) : NULL)) {
|
||||||
|
ao2_unlink(locals, p);
|
||||||
|
p->owner = ast_channel_release(p->owner);
|
||||||
|
ast_module_user_remove(p->u_owner);
|
||||||
|
p->chan = ast_channel_release(p->chan);
|
||||||
|
ast_module_user_remove(p->u_chan);
|
||||||
|
chan = NULL;
|
||||||
}
|
}
|
||||||
ao2_ref(p, -1); /* kill the ref from the alloc */
|
ao2_ref(p, -1); /* kill the ref from the alloc */
|
||||||
}
|
|
||||||
|
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user