mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
libFLAC/stream_decoder.c: Fix divide by zero error in FLAC__stream_decoder_seek_absolute
This commit is contained in:
committed by
Erik de Castro Lopo
parent
159cd6c41a
commit
d7b33142ec
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user