[vlc-devel] [PATCH] LUA: Add protocol to vlc.path

Rémi Denis-Courmont remi at remlab.net
Wed Jan 4 22:35:17 CET 2012


Le mercredi 4 janvier 2012 23:14:40 Gaurav Narula, vous avez écrit :
> ---
>  modules/lua/demux.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)

Does this not break backward compatibility with existing LUA demuxers?
> 
> diff --git a/modules/lua/demux.c b/modules/lua/demux.c
> index 169d668..029c958 100644
> --- a/modules/lua/demux.c
> +++ b/modules/lua/demux.c
> @@ -153,7 +153,13 @@ static int probe_luascript( vlc_object_t *p_this,
> const char * psz_filename, luaopen_stream( L );
>      luaopen_variables( L );
>      luaopen_xml( L );
> -    lua_pushstring( L, p_demux->psz_location );
> +
> +    char *protocol = malloc(strlen(p_demux->psz_location) +
> strlen(p_demux->psz_access) + 5); +    strcpy(protocol,
> p_demux->psz_access);

This is undefined if malloc() fails.

> +    strcat(protocol, "://");
> +    strcat(protocol, p_demux->psz_location);

asprintf() would be far more straightforward.

> +
> +    lua_pushstring( L, protocol );
>      lua_setfield( L, -2, "path" );
>      lua_pushstring( L, p_demux->psz_access );
>      lua_setfield( L, -2, "access" );

This leaks memory.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list