Commit b56560d7 authored by Fabio Ritrovato's avatar Fabio Ritrovato

Lua SD: check if p_input exists before using it

parent 18cb2997
...@@ -120,7 +120,8 @@ static int vlclua_sd_add_node( lua_State *L ) ...@@ -120,7 +120,8 @@ static int vlclua_sd_add_node( lua_State *L )
"vlc://nop", "vlc://nop",
name, 0, NULL, 0, name, 0, NULL, 0,
-1, ITEM_TYPE_NODE ); -1, ITEM_TYPE_NODE );
free( name ); if( p_input )
{
lua_getfield( L, -1, "arturl" ); lua_getfield( L, -1, "arturl" );
if( lua_isstring( L, -1 ) && strcmp( lua_tostring( L, -1 ), "" ) ) if( lua_isstring( L, -1 ) && strcmp( lua_tostring( L, -1 ), "" ) )
{ {
...@@ -143,6 +144,8 @@ static int vlclua_sd_add_node( lua_State *L ) ...@@ -143,6 +144,8 @@ static int vlclua_sd_add_node( lua_State *L )
} }
lua_setmetatable( L, -2 ); lua_setmetatable( L, -2 );
} }
free( name );
}
else else
msg_Err( p_sd, "vlc.sd.add_node: the \"title\" parameter can't be empty" ); msg_Err( p_sd, "vlc.sd.add_node: the \"title\" parameter can't be empty" );
} }
...@@ -168,7 +171,8 @@ static int vlclua_sd_add_item( lua_State *L ) ...@@ -168,7 +171,8 @@ static int vlclua_sd_add_item( lua_State *L )
i_options, i_options,
(const char **)ppsz_options, (const char **)ppsz_options,
VLC_INPUT_OPTION_TRUSTED, -1 ); VLC_INPUT_OPTION_TRUSTED, -1 );
free( psz_path ); if( p_input )
{
vlclua_read_meta_data( p_sd, L, p_input ); vlclua_read_meta_data( p_sd, L, p_input );
/* This one is to be tested... */ /* This one is to be tested... */
vlclua_read_custom_meta_data( p_sd, L, p_input ); vlclua_read_custom_meta_data( p_sd, L, p_input );
...@@ -190,6 +194,8 @@ static int vlclua_sd_add_item( lua_State *L ) ...@@ -190,6 +194,8 @@ static int vlclua_sd_add_item( lua_State *L )
} }
lua_setmetatable( L, -2 ); lua_setmetatable( L, -2 );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
}
free( psz_path );
while( i_options > 0 ) while( i_options > 0 )
free( ppsz_options[--i_options] ); free( ppsz_options[--i_options] );
free( ppsz_options ); free( ppsz_options );
...@@ -237,7 +243,8 @@ static int vlclua_node_add_subitem( lua_State *L ) ...@@ -237,7 +243,8 @@ static int vlclua_node_add_subitem( lua_State *L )
psz_path, i_options, psz_path, i_options,
(const char **)ppsz_options, (const char **)ppsz_options,
VLC_INPUT_OPTION_TRUSTED, -1 ); VLC_INPUT_OPTION_TRUSTED, -1 );
free( psz_path ); if( p_input )
{
vlclua_read_meta_data( p_sd, L, p_input ); vlclua_read_meta_data( p_sd, L, p_input );
/* This one is to be tested... */ /* This one is to be tested... */
vlclua_read_custom_meta_data( p_sd, L, p_input ); vlclua_read_custom_meta_data( p_sd, L, p_input );
...@@ -259,6 +266,8 @@ static int vlclua_node_add_subitem( lua_State *L ) ...@@ -259,6 +266,8 @@ static int vlclua_node_add_subitem( lua_State *L )
} }
lua_setmetatable( L, -2 ); lua_setmetatable( L, -2 );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
}
free( psz_path );
while( i_options > 0 ) while( i_options > 0 )
free( ppsz_options[--i_options] ); free( ppsz_options[--i_options] );
free( ppsz_options ); free( ppsz_options );
...@@ -290,7 +299,8 @@ static int vlclua_node_add_node( lua_State *L ) ...@@ -290,7 +299,8 @@ static int vlclua_node_add_node( lua_State *L )
"vlc://nop", "vlc://nop",
name, 0, NULL, 0, name, 0, NULL, 0,
-1, ITEM_TYPE_NODE ); -1, ITEM_TYPE_NODE );
free( name ); if( p_input )
{
lua_getfield( L, -1, "arturl" ); lua_getfield( L, -1, "arturl" );
if( lua_isstring( L, -1 ) && strcmp( lua_tostring( L, -1 ), "" ) ) if( lua_isstring( L, -1 ) && strcmp( lua_tostring( L, -1 ), "" ) )
{ {
...@@ -313,6 +323,8 @@ static int vlclua_node_add_node( lua_State *L ) ...@@ -313,6 +323,8 @@ static int vlclua_node_add_node( lua_State *L )
} }
lua_setmetatable( L, -2 ); lua_setmetatable( L, -2 );
} }
free( name );
}
else else
msg_Err( p_sd, "node:add_node: the \"title\" parameter can't be empty" ); msg_Err( p_sd, "node:add_node: the \"title\" parameter can't be empty" );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment