aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-06-13 10:52:35 +0200
committerAnton Khirnov <anton@khirnov.net>2012-06-13 13:58:58 +0200
commit9cdf74f904f76b2a1da474a2290c7e9ed34dd431 (patch)
treed4169ea9067c26ce859c7bf70ededa76f7dad609
parentce03b0881a941b64c8478aaf7ff759a7fb43a382 (diff)
downloadffmpeg-9cdf74f904f76b2a1da474a2290c7e9ed34dd431.tar.gz
lavfi/audio: use av_samples_copy() instead of custom code.
Fixes a possible invalid write, found by Nicolas George.
-rw-r--r--libavfilter/audio.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index 31839bb34b..a6fef9d273 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -185,10 +185,6 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
/* prepare to copy the samples if the buffer has insufficient permissions */
if ((dst->min_perms & samplesref->perms) != dst->min_perms ||
dst->rej_perms & samplesref->perms) {
- int i, planar = av_sample_fmt_is_planar(samplesref->format);
- int planes = !planar ? 1:
- av_get_channel_layout_nb_channels(samplesref->audio->channel_layout);
-
av_log(link->dst, AV_LOG_DEBUG,
"Copying audio data in avfilter (have perms %x, need %x, reject %x)\n",
samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
@@ -199,8 +195,10 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
/* Copy actual data into new samples buffer */
- for (i = 0; i < planes; i++)
- memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]);
+ av_samples_copy(link->cur_buf->extended_data, samplesref->extended_data,
+ 0, 0, samplesref->audio->nb_samples,
+ av_get_channel_layout_nb_channels(link->channel_layout),
+ link->format);
avfilter_unref_buffer(samplesref);
} else