diff options
author | Neelkamal Semwal <neelkamal.semwal@ittiam.com> | 2020-10-21 18:30:47 +0530 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2021-03-15 13:46:20 +1100 |
commit | d7b33142ecb4e64b7eaf54564d6ad6e7f20a6c5d (patch) | |
tree | fa3a9162ff206aa4e179235355f2efe8cea41cc6 | |
parent | 159cd6c41a6ec17b36d74043c45a3aa64de90d5e (diff) | |
download | flac-d7b33142ecb4e64b7eaf54564d6ad6e7f20a6c5d.tar.gz |
libFLAC/stream_decoder.c: Fix divide by zero error in FLAC__stream_decoder_seek_absolute
-rw-r--r-- | src/libFLAC/stream_decoder.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index aa63b2ca..3ca7f44f 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -3130,8 +3130,10 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s /* a little less accurate: */ if(upper_bound - lower_bound < 0xffffffff) pos = (FLAC__int64)lower_bound + (FLAC__int64)(((target_sample - lower_bound_sample) * (upper_bound - lower_bound)) / (upper_bound_sample - lower_bound_sample)) - approx_bytes_per_frame; - else /* @@@ WATCHOUT, ~2TB limit */ - pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8)) / ((upper_bound_sample - lower_bound_sample)>>16)) - approx_bytes_per_frame; + else { /* @@@ WATCHOUT, ~2TB limit */ + FLAC__uint64 ratio = (1<<16) / (upper_bound_sample - lower_bound_sample); + pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8) * ratio)) - approx_bytes_per_frame; + } #endif if(pos >= (FLAC__int64)upper_bound) pos = (FLAC__int64)upper_bound - 1; |