[vlc-devel] [PATCH 1/3] avio: fix potential memory leak

Rémi Denis-Courmont remi at remlab.net
Fri Aug 5 10:18:34 CEST 2016


Le 2016-08-05 09:20, Steve Lhomme a écrit :
> ---
>  modules/access/avio.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/modules/access/avio.c b/modules/access/avio.c
> index 3a3b478..1efa5fa 100644
> --- a/modules/access/avio.c
> +++ b/modules/access/avio.c
> @@ -158,10 +158,9 @@ int OpenAvio(vlc_object_t *object)
>      };
>      AVDictionary *options = NULL;
>      char *psz_opts = var_InheritString(access, "avio-options");
> -    if (psz_opts && *psz_opts) {
> +    if (psz_opts && *psz_opts)
>          options = vlc_av_get_options(psz_opts);
> -        free(psz_opts);
> -    }
> +    free(psz_opts);

I don't see a (fix for a) leak there because (*psz_opts) is a 
tautology.

Ditto below.

>      ret = avio_open2(&sys->context, url, AVIO_FLAG_READ, &cb, 
> &options);
>      AVDictionaryEntry *t = NULL;
>      while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX)))
> @@ -238,10 +237,9 @@ int OutOpenAvio(vlc_object_t *object)
>  #else
>      AVDictionary *options = NULL;
>      char *psz_opts = var_InheritString(access, "sout-avio-options");
> -    if (psz_opts && *psz_opts) {
> +    if (psz_opts && *psz_opts)
>          options = vlc_av_get_options(psz_opts);
> -        free(psz_opts);
> -    }
> +    free(psz_opts);
>      ret = avio_open2(&sys->context, access->psz_path, 
> AVIO_FLAG_WRITE,
>                       NULL, &options);
>      AVDictionaryEntry *t = NULL;

-- 
Rémi Denis-Courmont
http://www.remlab.net/


More information about the vlc-devel mailing list