[FFmpeg-devel] [PATCH 1/3] lavf/tee: fix leak of strdup/strtoked buffer.

Stefano Sabatini stefasab at gmail.com
Mon Oct 21 17:27:07 CEST 2013


On date Monday 2013-10-21 17:08:46 +0200, Nicolas George encoded:
> Fix CID 1108606.
> 
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavformat/tee.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 40b59a4..171a827 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -102,10 +102,10 @@ fail:
>  static int parse_bsfs(void *log_ctx, const char *bsfs_spec,
>                        AVBitStreamFilterContext **bsfs)
>  {
> -    char *bsf_name, *buf, *saveptr;
> +    char *bsf_name, *buf, *dup, *saveptr;
>      int ret = 0;
>  
> -    if (!(buf = av_strdup(bsfs_spec)))
> +    if (!(dup = buf = av_strdup(bsfs_spec)))
>          return AVERROR(ENOMEM);
>  
>      while (bsf_name = av_strtok(buf, ",", &saveptr)) {
> @@ -128,7 +128,7 @@ static int parse_bsfs(void *log_ctx, const char *bsfs_spec,
>      }
>  
>  end:
> -    av_free(buf);
> +    av_free(dup);
>      return ret;
>  }
>  
> -- 
> 1.8.4.rc3

Or use p to mark the sliding pointer, and buf the start of the
buffer.

LGTM, thanks.
-- 
FFmpeg = Foolish and Freak Monstrous Philosophical Elected Game


More information about the ffmpeg-devel mailing list