X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fplaylist%2Floadsave.c;h=3ffbe5715a25931f2a4be635bcce20a53253a9f0;hb=d666030b2349e8a710fcba4d2cabb912cc700580;hp=1579db38548ca83b2b893dca163b4e4ee320850e;hpb=df61d33b06e2b3cbbe746b2f5a9bea5b370c24ff;p=vlc diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c index 1579db3854..3ffbe5715a 100644 --- a/src/playlist/loadsave.c +++ b/src/playlist/loadsave.c @@ -24,7 +24,7 @@ # include "config.h" #endif -#include +#include #include #include #include "playlist_internal.h" @@ -108,7 +108,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event, int playlist_MLLoad( playlist_t *p_playlist ) { - const char *psz_datadir = p_playlist->p_libvlc->psz_datadir; + char *psz_datadir = config_GetUserDataDir(); char *psz_uri = NULL; input_item_t *p_input; @@ -127,18 +127,18 @@ int playlist_MLLoad( playlist_t *p_playlist ) struct stat p_stat; /* checks if media library file is present */ if( utf8_stat( psz_uri , &p_stat ) ) - { - free( psz_uri ); - return VLC_EGENERIC; - } + goto error; free( psz_uri ); + /* FIXME: WTF? stat() should never be used right before open()! */ if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xspf", psz_datadir ) == -1 ) { psz_uri = NULL; goto error; } + free( psz_datadir ); + psz_datadir = NULL; const char *const psz_option = "meta-file"; /* that option has to be cleaned in input_item_subitem_added() */ @@ -183,12 +183,13 @@ int playlist_MLLoad( playlist_t *p_playlist ) error: free( psz_uri ); + free( psz_datadir ); return VLC_ENOMEM; } int playlist_MLDump( playlist_t *p_playlist ) { - char *psz_datadir = p_playlist->p_libvlc->psz_datadir; + char *psz_datadir = config_GetUserDataDir(); if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS; if( !psz_datadir ) /* XXX: This should never happen */ { @@ -196,9 +197,9 @@ int playlist_MLDump( playlist_t *p_playlist ) return VLC_EGENERIC; } - char psz_dirname[ strlen( psz_datadir ) - + sizeof( DIR_SEP "ml.xspf")]; - sprintf( psz_dirname, "%s", psz_datadir ); + char psz_dirname[ strlen( psz_datadir ) + sizeof( DIR_SEP "ml.xspf")]; + strcpy( psz_dirname, psz_datadir ); + free( psz_datadir ); if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) ) { return VLC_EGENERIC;