[FFmpeg-devel] [PATCH] libavfilter/af_atempo: Fix uninitialized memory access

pkoshevoy at gmail.com pkoshevoy at gmail.com
Thu Apr 18 06:33:34 CEST 2013


From: Pavel Koshevoy <pkoshevoy at gmail.com>

valgrind reported uninitialized memory access which was caused by
incorrect number of samples being passed to push_samples(..)

Signed-off-by: Pavel Koshevoy <pkoshevoy at gmail.com>
---
 libavfilter/af_atempo.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index 3e2bc06..f5c5da8 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -1061,7 +1061,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer)
     ATempoContext *atempo = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
 
-    int ret = 0;
+    int ret = AVERROR(EAGAIN);
     int n_in = src_buffer->nb_samples;
     int n_out = (int)(0.5 + ((double)n_in) / atempo->tempo);
 
@@ -1082,7 +1082,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer)
         yae_apply(atempo, &src, src_end, &atempo->dst, atempo->dst_end);
 
         if (atempo->dst == atempo->dst_end) {
-            ret = push_samples(atempo, outlink, n_out);
+            int n_samples = ((atempo->dst - atempo->dst_buffer->data[0]) /
+                             atempo->stride);
+            ret = push_samples(atempo, outlink, n_samples);
             if (ret < 0)
                 goto end;
         }
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list