From 1c79a23b8e2dfa20fbb7ebc368157c122722f873 Mon Sep 17 00:00:00 2001 From: Steve Murphy Date: Tue, 2 Sep 2008 22:50:59 +0000 Subject: [PATCH] Merged revisions 140670 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r140670 | murf | 2008-09-02 16:15:57 -0600 (Tue, 02 Sep 2008) | 14 lines (closes issue #13409) Reported by: tomaso Patches: asterisk-1.6.0-rc2-cdrmemleak.patch uploaded by tomaso (license 564) I basically spent the day, verifying that this patch solves the problem, and doesn't hurt in non-problem cases. Why valgrind did not plainly reveal this leak absolutely mystifies and stuns me. Many, many thanks to tomaso for finding and providing the fix. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@140691 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/channel.c | 6 ++++++ main/pbx.c | 1 + 2 files changed, 7 insertions(+) diff --git a/main/channel.c b/main/channel.c index 77a7908025..2596a0037a 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1360,6 +1360,11 @@ void ast_channel_free(struct ast_channel *chan) /* Destroy the jitterbuffer */ ast_jb_destroy(chan); + + if (chan->cdr) { + ast_cdr_free(chan->cdr); + chan->cdr = NULL; + } ast_mutex_destroy(&chan->lock_dont_use); @@ -1642,6 +1647,7 @@ int ast_hangup(struct ast_channel *chan) ast_cdr_end(chan->cdr); ast_cdr_detach(chan->cdr); + chan->cdr = NULL; } ast_channel_free(chan); diff --git a/main/pbx.c b/main/pbx.c index db4a79552e..59ba133e87 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -7087,6 +7087,7 @@ static int ast_pbx_outgoing_cdr_failed(void) ast_cdr_end(chan->cdr); ast_cdr_failed(chan->cdr); /* set the status to failed */ ast_cdr_detach(chan->cdr); /* post and free the record */ + chan->cdr = NULL; ast_channel_free(chan); /* free the channel */ return 0; /* success */