[opus] [PATCH] op_fetch_and_process_page: fix int64 overflow
James Zern
jzern at google.com
Thu Dec 7 23:25:28 UTC 2017
check for overflow with a negative diff
---
src/opusfile.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/opusfile.c b/src/opusfile.c
index 140503e..8b000a2 100644
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -2078,7 +2078,11 @@ static int op_fetch_and_process_page(OggOpusFile *_of,
&&OP_LIKELY(diff<total_duration)){
cur_packet_gp=prev_packet_gp;
for(pi=0;pi<op_count;pi++){
- diff=durations[pi]-diff;
+ /*Check for overflow.*/
+ if(diff<0&&OP_UNLIKELY(OP_INT64_MAX+diff<durations[pi])){
+ diff=durations[pi]+1;
+ }
+ else diff=durations[pi]-diff;
/*If we have samples to trim...*/
if(diff>0){
/*If we trimmed the entire packet, stop (the spec says encoders
--
2.15.1.424.g9478a66081-goog
More information about the opus
mailing list