[FFmpeg-devel] [PATCH] swr: handle 64bit overflow check in multiple_resample().

Ronald S. Bultje rsbultje at gmail.com
Mon Jun 9 14:09:49 CEST 2014


---
 libswresample/resample.c          | 2 ++
 libswresample/resample_template.c | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libswresample/resample.c b/libswresample/resample.c
index a657a03..6d30920 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -335,9 +335,11 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A
     int i, ret= -1;
     int av_unused mm_flags = av_get_cpu_flags();
     int need_emms= 0;
+    int max_src_size = (INT64_MAX >> (c->phase_shift+1)) / c->src_incr;
 
     if (c->compensation_distance)
         dst_size = FFMIN(dst_size, c->compensation_distance);
+    src_size = FFMIN(src_size, max_src_size);
 
     for(i=0; i<dst->ch_count; i++){
 #if HAVE_MMXEXT_INLINE
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c
index 5151f58..73a672a 100644
--- a/libswresample/resample_template.c
+++ b/libswresample/resample_template.c
@@ -133,8 +133,7 @@ int RENAME(swri_resample)(ResampleContext *c, DELEM *dst, const DELEM *src, int
         av_assert2(index >= 0);
         *consumed= index;
         index = 0;
-    } else if (index >= 0 &&
-               src_size*(int64_t)c->src_incr < (INT64_MAX >> (c->phase_shift+1))) {
+    } else if (index >= 0) {
         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;
-- 
1.8.5.5



More information about the ffmpeg-devel mailing list