From 95374ad3ca67da51882df1bf3fa79f42bd363102 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 30 Apr 2010 10:22:05 +0000 Subject: Re #969: Fixed bug division by zero in JB progressive discard code, caused by possibility of uninitialized burst level after JB switches status INITIALIZING -> PROCESSING (thanks Janos Tolgyesi and Tamàs Solymosi for the report and investigation). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3154 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia/jbuf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pjmedia') diff --git a/pjmedia/src/pjmedia/jbuf.c b/pjmedia/src/pjmedia/jbuf.c index dd530e99..f7ba2c95 100644 --- a/pjmedia/src/pjmedia/jbuf.c +++ b/pjmedia/src/pjmedia/jbuf.c @@ -648,6 +648,10 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper) */ if (++jb->jb_init_cycle_cnt >= INIT_CYCLE && oper == JB_OP_GET) { jb->jb_status = JB_STATUS_PROCESSING; + /* To make sure the burst calculation will be done right after + * this, adjust burst level if it exceeds max burst level. + */ + jb->jb_level = PJ_MIN(jb->jb_level, jb->jb_max_burst); } else { jb->jb_level = 0; return; @@ -660,7 +664,7 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper) * the GET op may be idle, in this case, we better skip the jitter * calculation. */ - if (oper == JB_OP_GET && jb->jb_level < jb->jb_max_burst) + if (oper == JB_OP_GET && jb->jb_level <= jb->jb_max_burst) jbuf_calculate_jitter(jb); jb->jb_level = 0; -- cgit v1.2.3