[vlc-devel] [PATCH] input: fix use after free

Rémi Denis-Courmont remi at remlab.net
Fri Aug 1 11:42:44 CEST 2014


Le 2014-08-01 06:46, Tristan Matthews a écrit :
> ---
>  src/input/input.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/input/input.c b/src/input/input.c
> index 87bbfe8..363b1a4 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -2413,17 +2413,24 @@ static int InputSourceInit( input_thread_t 
> *p_input,
>
>          if( in->p_demux == NULL )
>          {
> +            /* cache info since it may be freed in stream_Delete */
> +            char *err_str;
> +            if( asprintf( &err_str, "no suitable demux module for
> `%s/%s://%s'",
> +                          psz_access, psz_demux, psz_path ) < 0 )
> +                err_str = NULL;
> +

Why add so much code and a new error case when you can just move one 
line?

>              stream_Delete( p_stream );
>              if( vlc_object_alive( p_input ) )
>              {
> -                msg_Err( p_input, "no suitable demux module for
> `%s/%s://%s'",
> -                         psz_access, psz_demux, psz_path );
> +                if( err_str )
> +                    msg_Err( p_input, "%s", err_str );
>                  if( !b_in_can_fail )
>                      dialog_Fatal( VLC_OBJECT( p_input ),
>                                    _("VLC can't recognize the input's
> format"),
>                                    _("The format of '%s' cannot be
> detected. "
>                                      "Have a look at the log for
> details."), psz_mrl );
>              }
> +            free( err_str );
>              goto error;
>          }
>          assert( in->p_demux->pf_demux != NULL );

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list