aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-06-02 00:57:08 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-02 00:57:08 +0200
commit2c23f87c8553d5cfc1c130bc3e487660a3c826ec (patch)
treee6be42f72697e275a41545462152d98908fc6f36
parent9b53853756f7e7535b4178054757fc2cb90408f3 (diff)
downloadffmpeg-2c23f87c8553d5cfc1c130bc3e487660a3c826ec.tar.gz
swr/resample_template: prevent end_index from overflowing and add check for delta_frac overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libswresample/resample_template.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c
index 3fc83158bc..bb36e65c17 100644
--- a/libswresample/resample_template.c
+++ b/libswresample/resample_template.c
@@ -134,8 +134,10 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
av_assert2(index >= 0);
*consumed= index;
index = 0;
- } else if (compensation_distance == 0 && index >= 0) {
- int64_t end_index = (1 + src_size - c->filter_length) << c->phase_shift;
+ } else if (compensation_distance == 0 &&
+ index >= 0 &&
+ src_size*(int64_t)c->src_incr < (INT64_MAX >> (c->phase_shift+1))) {
+ int64_t end_index = (1LL + src_size - c->filter_length) << c->phase_shift;
int64_t delta_frac = (end_index - index) * c->src_incr - c->frac;
int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;
int n = FFMIN(dst_size, delta_n);