[asterisk-commits] coreyfarrell: branch 11 r427019 - in /branches/11: funcs/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Nov 2 01:35:44 CST 2014


Author: coreyfarrell
Date: Sun Nov  2 01:35:36 2014
New Revision: 427019

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427019
Log:
func_jitterbuffer: fix frame leaks.

Fix code paths where it is possible for frames to leak.
Fix uninitialized variable in jb_get_fixed and jb_get_adaptive.

ASTERISK-22409 #related
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4128/

Modified:
    branches/11/funcs/func_jitterbuffer.c
    branches/11/main/abstract_jb.c

Modified: branches/11/funcs/func_jitterbuffer.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/funcs/func_jitterbuffer.c?view=diff&rev=427019&r1=427018&r2=427019
==============================================================================
--- branches/11/funcs/func_jitterbuffer.c (original)
+++ branches/11/funcs/func_jitterbuffer.c Sun Nov  2 01:35:36 2014
@@ -254,8 +254,14 @@
 		} else {
 			res = framedata->jb_impl->put(framedata->jb_obj, jbframe, now);
 		}
+
 		if (res == AST_JB_IMPL_OK) {
+			if (jbframe != frame) {
+				ast_frfree(frame);
+			}
 			frame = &ast_null_frame;
+		} else if (jbframe != frame) {
+			ast_frfree(jbframe);
 		}
 		putframe = 1;
 	}
@@ -282,6 +288,8 @@
 			}
 		}
 
+		ast_frfree(frame);
+		frame = &ast_null_frame;
 		res = framedata->jb_impl->get(framedata->jb_obj, &frame, now, framedata->timer_interval);
 		switch (res) {
 		case AST_JB_IMPL_OK:
@@ -294,6 +302,7 @@
 		case AST_JB_IMPL_INTERP:
 			if (framedata->last_format.id) {
 				struct ast_frame tmp = { 0, };
+
 				tmp.frametype = AST_FRAME_VOICE;
 				ast_format_copy(&tmp.subclass.format, &framedata->last_format);
 				/* example: 8000hz / (1000 / 20ms) = 160 samples */
@@ -301,11 +310,13 @@
 				tmp.delivery = ast_tvadd(framedata->start_tv, ast_samp2tv(next, 1000));
 				tmp.offset = AST_FRIENDLY_OFFSET;
 				tmp.src  = "func_jitterbuffer interpolation";
+				ast_frfree(frame);
 				frame = ast_frdup(&tmp);
 				break;
 			}
 			/* else fall through */
 		case AST_JB_IMPL_NOFRAME:
+			ast_frfree(frame);
 			frame = &ast_null_frame;
 			break;
 		}

Modified: branches/11/main/abstract_jb.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/abstract_jb.c?view=diff&rev=427019&r1=427018&r2=427019
==============================================================================
--- branches/11/main/abstract_jb.c (original)
+++ branches/11/main/abstract_jb.c Sun Nov  2 01:35:36 2014
@@ -647,7 +647,7 @@
 static int jb_get_fixed(void *jb, struct ast_frame **fout, long now, long interpl)
 {
 	struct fixed_jb *fixedjb = (struct fixed_jb *) jb;
-	struct fixed_jb_frame frame;
+	struct fixed_jb_frame frame = { .data = &ast_null_frame };
 	int res;
 
 	res = fixed_jb_get(fixedjb, &frame, now, interpl);
@@ -743,7 +743,7 @@
 static int jb_get_adaptive(void *jb, struct ast_frame **fout, long now, long interpl)
 {
 	jitterbuf *adaptivejb = (jitterbuf *) jb;
-	jb_frame frame;
+	jb_frame frame = { .data = &ast_null_frame };
 	int res;
 
 	res = jb_get(adaptivejb, &frame, now, interpl);




More information about the asterisk-commits mailing list