Commit 0ac8ff61 authored by Luca Barbato's avatar Luca Barbato

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: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 82de8d71
...@@ -434,7 +434,9 @@ int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src) ...@@ -434,7 +434,9 @@ int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src)
int bps = av_get_bytes_per_sample(c->avr->internal_sample_fmt); int bps = av_get_bytes_per_sample(c->avr->internal_sample_fmt);
int i; 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) { if (ret < 0) {
av_log(c->avr, AV_LOG_ERROR, "Error reallocating resampling buffer\n"); av_log(c->avr, AV_LOG_ERROR, "Error reallocating resampling buffer\n");
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment