1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

flac: fix realloc loop with invalid flac files

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Thomas Guillem 2015-04-16 18:33:31 +02:00 committed by Luca Barbato
parent 2cc3936599
commit b18346817d

View File

@ -565,6 +565,15 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
nb_desired * FLAC_AVG_FRAME_SIZE);
}
if (!av_fifo_space(fpc->fifo_buf) &&
av_fifo_size(fpc->fifo_buf) / FLAC_AVG_FRAME_SIZE >
fpc->nb_headers_buffered * 10) {
/* There is less than one valid flac header buffered for 10 headers
* buffered. Therefore the fifo is most likely filled with invalid
* data and the input is not a flac file. */
goto handle_error;
}
/* Fill the buffer. */
if (av_fifo_realloc2(fpc->fifo_buf,
(read_end - read_start) + av_fifo_size(fpc->fifo_buf)) < 0) {