Commit 82adfb61 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

Fix intermediate overflow in op_pcm_total().

Although link enumeration ensures the return value is in range, the
 order of operations allows the intermediate value pcm_total+diff
 to overflow the range of a 64-bit int.
Add parentheses to ensure this does not happen.
Thanks to Felcia Lim for the report.

Fixes #2330
parent 4174c26e
......@@ -1753,7 +1753,7 @@ ogg_int64_t op_pcm_total(const OggOpusFile *_of,int _li){
}
OP_ALWAYS_TRUE(!op_granpos_diff(&diff,
links[_li].pcm_end,links[_li].pcm_start));
return pcm_total+diff-links[_li].head.pre_skip;
return pcm_total+(diff-links[_li].head.pre_skip);
}
const OpusHead *op_head(const OggOpusFile *_of,int _li){
......
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