From 7d03892ea83c47d175a63069eae1fd490080282a Mon Sep 17 00:00:00 2001 From: Jonathan Rose Date: Thu, 24 Oct 2013 19:39:49 +0000 Subject: [PATCH] jitterbuf: Fix memory leak on jitter buffer reset (issue ASTERISK-22467) Reported by: Corey Farrell Patches: jitterbuf-jb_reset-leak-1.8.patch jitterbuf-jb_reset-leak-11up.patch git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@401786 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/jitterbuf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/jitterbuf.c b/main/jitterbuf.c index 36ebb27850..7e439a1367 100644 --- a/main/jitterbuf.c +++ b/main/jitterbuf.c @@ -71,12 +71,14 @@ static void decrement_losspct(jitterbuf *jb) jb->info.losspct = (499 * jb->info.losspct)/500; } -void jb_reset(jitterbuf *jb) +void jb_reset(jitterbuf *jb) { - /* only save settings */ + /* only save settings and free list */ jb_conf s = jb->info.conf; + jb_frame *fr = jb->free; memset(jb, 0, sizeof(*jb)); jb->info.conf = s; + jb->free = fr; /* initialize length, using the default value */ jb->info.current = jb->info.target = jb->info.conf.target_extra = JB_TARGET_EXTRA; @@ -87,7 +89,7 @@ jitterbuf * jb_new() { jitterbuf *jb; - if (!(jb = ast_malloc(sizeof(*jb)))) + if (!(jb = ast_calloc(1, sizeof(*jb)))) return NULL; jb_reset(jb);