]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
(closes issue #13409)
authorSteve Murphy <murf@digium.com>
Tue, 2 Sep 2008 22:15:57 +0000 (22:15 +0000)
committerSteve Murphy <murf@digium.com>
Tue, 2 Sep 2008 22:15:57 +0000 (22:15 +0000)
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/branches/1.4@140670 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c
main/pbx.c

index 3006e71cb24569273cbe47dfa133de048dbd49c4..3bbccff7cd1f59dc4f9d797872faa4a4df3ed0e4 100644 (file)
@@ -1277,6 +1277,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);
 
@@ -1523,6 +1528,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);
index f4e5a150cd9106a106eb7d55b779003568dff15c..f4dfd0d5278e93a0524d00206df360eabfbce614 100644 (file)
@@ -4972,6 +4972,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 */