[FFmpeg-devel] [PATCH] lavf/concatdec: avoid leaking URLs.
Stefano Sabatini
stefasab at gmail.com
Wed Dec 12 13:28:33 CET 2012
On date Wednesday 2012-12-12 12:22:38 +0100, Nicolas George encoded:
> Use av_realloc instead of av_realloc_f to keep the original
> array in case of failure: it is freed in full by the fail label.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavformat/concatdec.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> index 29233e2..858701f 100644
> --- a/libavformat/concatdec.c
> +++ b/libavformat/concatdec.c
> @@ -69,9 +69,11 @@ static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
>
> if (cat->nb_files >= *nb_files_alloc) {
> unsigned n = FFMAX(*nb_files_alloc * 2, 16);
> - if (n <= cat->nb_files ||
> - !(cat->files = av_realloc_f(cat->files, n, sizeof(*cat->files))))
> + ConcatFile *new_files;
> + if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
> + !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
> return AVERROR(ENOMEM);
> + cat->files = new_files;
> *nb_files_alloc = n;
> }
LGTM, thanks.
--
FFmpeg = Fast and Friendly Murdering Perennial Extensive Gymnast
More information about the ffmpeg-devel
mailing list