From 389c19e1729f20371fcb0a6294a00ca32966ab27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sun, 30 Dec 2007 18:40:53 +0000 Subject: [PATCH] fix #1244 --- modules/demux/playlist/xspf.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c index 131e6cfb44..101bd729b2 100644 --- a/modules/demux/playlist/xspf.c +++ b/modules/demux/playlist/xspf.c @@ -537,19 +537,29 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE if( psz_uri ) { - if( p_demux->p_sys->psz_base && + if( ( p_demux->p_sys->psz_base || + strrchr( p_demux->psz_path, DIR_SEP_CHAR ) ) && !strstr( psz_uri, "://" ) ) { - char* psz_tmp = malloc( - strlen(p_demux->p_sys->psz_base) + - strlen(psz_uri) +1 ); + char *psz_baseref = p_demux->p_sys->psz_base; + size_t i_baselen; + if( psz_baseref ) + i_baselen = strlen( psz_baseref ); + else + { + psz_baseref = p_demux->psz_path; + i_baselen = strrchr( psz_baseref, DIR_SEP_CHAR ) + - psz_baseref + 1; + } + char* psz_tmp = malloc( i_baselen + + strlen( psz_uri ) + 1 ); if( !psz_tmp ) { msg_Err( p_demux, "out of memory"); return VLC_FALSE; } - sprintf( psz_tmp, "%s%s", - p_demux->p_sys->psz_base, psz_uri ); + strncpy( psz_tmp, psz_baseref, i_baselen ); + strcpy( psz_tmp + i_baselen, psz_uri ); free( psz_uri ); psz_uri = psz_tmp; } -- 2.20.1