player: fix --end with large values

Causea a simple integer overflow.

Fixes #4650.
This commit is contained in:
wm4 2017-08-08 14:11:58 +02:00
parent 0b10a07b63
commit 8ef50016be
1 changed files with 5 additions and 2 deletions

View File

@ -800,8 +800,11 @@ static bool copy_output(struct MPContext *mpctx, struct mp_audio_buffer *outbuf,
if (endpts != MP_NOPTS_VALUE) {
double rate = afs->output.rate / mpctx->audio_speed;
double curpts = written_audio_pts(mpctx);
if (curpts != MP_NOPTS_VALUE)
maxsamples = (endpts - curpts - mpctx->opts->audio_delay) * rate;
if (curpts != MP_NOPTS_VALUE) {
double remaining =
(endpts - curpts - mpctx->opts->audio_delay) * rate;
maxsamples = MPCLAMP(remaining, 0, INT_MAX);
}
}
struct mp_audio *mpa = af_read_output_frame(afs);