Commit 7546679c authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

Fix a possible divide-by-zero.

We were attempting to ensure a minimum spacing between granule
 positions when guessing the start of a link location.
However, we took a strictly-positive granule position, added a
 fixed increment with op_granpos_add(), and checked if
 op_granpos_add() failed.
op_granpos_add() only fails if the sum would have overflowed past
 zero, which can never happen when adding two strictly positive
 granule positions.
Instead, we need to check if the result becomes negative (which is
 a legal granule position, but violates our assumptions in the
 search).

Thanks to Felicia Lim for the report.
parent 6452e838
Pipeline #2136 passed with stage
in 58 seconds
......@@ -1067,10 +1067,9 @@ static opus_int64 op_predict_link_start(const OpusSeekRecord *_sr,int _nsr,
Therefore we require a minimum spacing between them, with the
expectation that while bitrates and granule position increments might
vary locally in quite complex ways, they are globally smooth.*/
if(OP_UNLIKELY(op_granpos_add(&gp2_min,gp1,OP_GP_SPACING_MIN)<0)){
/*No granule position would satisfy us.*/
continue;
}
OP_ALWAYS_TRUE(!op_granpos_add(&gp2_min,gp1,OP_GP_SPACING_MIN));
/*No granule position would satisfy us.*/
if(gp2_min<0)continue;
offset1=_sr[sri].offset;
serialno1=_sr[sri].serialno;
for(srj=sri;srj-->0;){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment