[vlc-commits] lua: fix crash introduced in 18c00a386 if a newly added input doesn' t have a parent (close #8869)

Felix Paul Kühne git at videolan.org
Mon Jul 1 12:03:35 CEST 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Jul  1 12:03:29 2013 +0200| [b2cce4d84b42200afd98346c42e223ce9b40a3e5] | committer: Felix Paul Kühne

lua: fix crash introduced in 18c00a386 if a newly added input doesn't have a parent (close #8869)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b2cce4d84b42200afd98346c42e223ce9b40a3e5
---

 modules/lua/vlc.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index a4b590b..d92b582 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -496,8 +496,10 @@ int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
                     input_item_t *p_input;
 
                     /* Read path and name */
-                    psz_oldurl = input_item_GetURI( p_parent );
-                    msg_Dbg( p_this, "old path: %s", psz_oldurl );
+                    if (p_parent) {
+                        psz_oldurl = input_item_GetURI( p_parent );
+                        msg_Dbg( p_this, "old path: %s", psz_oldurl );
+                    }
                     psz_path = lua_tostring( L, -1 );
                     msg_Dbg( p_this, "Path: %s", psz_path );
                     lua_getfield( L, -2, "name" );
@@ -547,14 +549,14 @@ int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
 
                     /* copy the original URL to the meta data, if "URL" is still empty */
                     char* url = input_item_GetURL( p_input );
-                    if( url == NULL )
+                    if( url == NULL && p_parent)
                     {
                         EnsureUTF8( psz_oldurl );
                         msg_Dbg( p_this, "meta-URL: %s", psz_oldurl );
                         input_item_SetURL ( p_input, psz_oldurl );
+                        free( psz_oldurl );
                     }
                     free( url );
-                    free( psz_oldurl );
 
                     /* copy the psz_name to the meta data, if "Title" is still empty */
                     char* title = input_item_GetTitle( p_input );



More information about the vlc-commits mailing list