diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2015-04-28 01:55:10 +0200 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-05-19 12:13:33 +0100 |
commit | 744d813bcf527481f2217428fa08bfee8642935b (patch) | |
tree | d988ce40e318f0955d49c3f239506733d5eda796 | |
parent | 844201e35fe575710be8218d45828df49b77f205 (diff) | |
download | ffmpeg-744d813bcf527481f2217428fa08bfee8642935b.tar.gz |
avresample: Reallocate the internal buffer to the correct size
Fixes the corner case in which the internal buffer size
is larger than input buffer provided and resizing it
before moving the left over samples would make it write
to now unallocated memory.
Bug-Id: 825
CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | libavresample/resample.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavresample/resample.c b/libavresample/resample.c index 4553b2c6eb..679e9e9ef4 100644 --- a/libavresample/resample.c +++ b/libavresample/resample.c @@ -432,7 +432,9 @@ int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src) int bps = av_get_bytes_per_sample(c->avr->internal_sample_fmt); int i; - ret = ff_audio_data_realloc(c->buffer, in_samples + c->padding_size); + ret = ff_audio_data_realloc(c->buffer, + FFMAX(in_samples, in_leftover) + + c->padding_size); if (ret < 0) { av_log(c->avr, AV_LOG_ERROR, "Error reallocating resampling buffer\n"); return AVERROR(ENOMEM); |