[FFmpeg-cvslog] swresample/resample: fix invert_initial_buffer() after flush

Michael Niedermayer git at videolan.org
Thu Oct 16 22:36:17 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Oct 16 21:18:15 2014 +0200| [f6bb2cd1b048a9169827368241769a2a7887efdd] | committer: Michael Niedermayer

swresample/resample: fix invert_initial_buffer() after flush

Fixes: asan_heap-uaf_2071250_7_139.ogg
Fixes: assertion failure
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6bb2cd1b048a9169827368241769a2a7887efdd
---

 libswresample/resample.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libswresample/resample.c b/libswresample/resample.c
index 2a8aa7e..d0f6e20 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -399,11 +399,11 @@ static int invert_initial_buffer(ResampleContext *c, AudioData *dst, const Audio
 
     res = num - *out_sz;
     *out_idx = c->filter_length + (c->index >> c->phase_shift);
-    *out_sz = 1 + c->filter_length * 2 - *out_idx;
+    *out_sz = FFMAX(*out_sz + c->filter_length,
+                    1 + c->filter_length * 2) - *out_idx;
     c->index &= c->phase_mask;
-    av_assert1(res > 0);
 
-    return res;
+    return FFMAX(res, 0);
 }
 
 struct Resampler const swri_resampler={



More information about the ffmpeg-cvslog mailing list