summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2012-05-23 20:39:22 +0000
committerJonathan Rose <jrose@digium.com>2012-05-23 20:39:22 +0000
commita1da70097ddf8d59e207ac023bca8473372d3427 (patch)
tree854d9a7012e5bbda9487c3061081965633271828
parent30666bf67d0c0edceb70356b434b159e91a212f2 (diff)
logger: Fix a potential callid reference leak discovered in development
Uncovered a nasty reference leak while I was writing some changes to chan_dahdi/sig_analog. Slapped myself around a bit after seeing that I performed the unchecked return causing this problem. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@367419 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--main/pbx.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 250737b22..5fe981d57 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5105,6 +5105,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
int autoloopflag;
int error = 0; /* set an error conditions */
struct ast_pbx *pbx;
+ struct ast_callid *callid;
/* A little initial setup here */
if (ast_channel_pbx(c)) {
@@ -5116,17 +5117,24 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
return -1;
}
- if (!ast_read_threadstorage_callid()) {
+ callid = ast_read_threadstorage_callid();
+ /* If the thread isn't already associated with a callid, we should create that association. */
+ if (!callid) {
/* Associate new PBX thread with the channel call id if it is availble.
* If not, create a new one instead.
*/
- struct ast_callid *callid;
- if (!(callid = ast_channel_callid(c))) {
+ callid = ast_channel_callid(c);
+ if (!callid) {
callid = ast_create_callid();
+ if (callid) {
+ ast_channel_callid_set(c, callid);
+ }
}
ast_callid_threadassoc_add(callid);
- ast_channel_callid_set(c, callid);
callid = ast_callid_unref(callid);
+ } else {
+ /* Nothing to do here, The thread is already bound to a callid. Let's just get rid of the reference. */
+ ast_callid_unref(callid);
}
ast_channel_pbx_set(c, pbx);