[opus] Antw: [PATCH 1/2] op_pcm_seek: fix int64 overflow
Ulrich Windl
Ulrich.Windl at rz.uni-regensburg.de
Tue Nov 21 07:32:21 UTC 2017
Hi!
I never inspected the Opus sources, but di you guys think that adding blanks (e.g. around binary operators) is a waste of time and storage space?
Regards,
Ulrich
>>> James Zern <jzern at google.com> schrieb am 20.11.2017 um 22:07 in Nachricht
<20171120210721.186099-2-jzern at google.com>:
> 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 72f1272..df326af 100644
> --- a/src/opusfile.c
> +++ b/src/opusfile.c
> @@ -2605,7 +2605,11 @@ int op_pcm_seek(OggOpusFile *_of,ogg_int64_t
> _pcm_offset){
> would be better just to do a full seek.*/
> if(OP_LIKELY(!op_granpos_diff(&diff,gp,pcm_start))){
> ogg_int64_t discard_count;
> - discard_count=_pcm_offset-diff;
> + /*Check for overflow.*/
> + if(diff<0&&OP_UNLIKELY(OP_INT64_MAX+diff<_pcm_offset)){
> + discard_count=0;
> + }
> + else discard_count=_pcm_offset-diff;
> /*We use a threshold of 90 ms instead of 80, since 80 ms is the
> _minimum_ we would have discarded after a full seek.
> Assuming 20 ms frames (the default), we'd discard 90 ms on
> average.*/
> --
> 2.15.0.448.gf294e3d99a-goog
>
> _______________________________________________
> opus mailing list
> opus at xiph.org
> http://lists.xiph.org/mailman/listinfo/opus
More information about the opus
mailing list