summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-08 14:11:58 +0200
committerwm4 <wm4@nowhere>2017-08-08 14:11:58 +0200
commit8ef50016befd8e684866a84c09dd0460d379e2ee (patch)
tree40b571582df1e3baba66ed07ce113f4cfe2b3045
parent0b10a07b6349f77abb7f2a14733c5704664301a1 (diff)
downloadmpv-8ef50016befd8e684866a84c09dd0460d379e2ee.tar.bz2
mpv-8ef50016befd8e684866a84c09dd0460d379e2ee.tar.xz
player: fix --end with large values
Causea a simple integer overflow. Fixes #4650.
-rw-r--r--player/audio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/player/audio.c b/player/audio.c
index 7a29b110ae..d1e4c83a9a 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -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);