From 50991f02d498a92d4e5441cc0c79cd293e92d69e Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 2 Dec 2017 22:49:21 +0200 Subject: [PATCH] mp4: use vlc_uri_resolve() (Also remove NULL deference on error.) --- modules/demux/mp4/mp4.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index 173c70d400..8df0c3eeb1 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include "../codec/cc.h" @@ -802,24 +803,24 @@ static int Open( vlc_object_t * p_this ) } else { - char *psz_absolute; - char *psz_path = strdup( p_demux->psz_location ); - char *end = strrchr( psz_path, '/' ); - if( end ) end[1] = '\0'; - else *psz_path = '\0'; - - if( asprintf( &psz_absolute, "%s://%s%s", - p_demux->psz_access, psz_path, psz_ref ) < 0 ) + char *psz_url; + if( asprintf( &psz_url, "%s://%s", p_demux->psz_access, + p_demux->psz_location ) < 0 ) { free( psz_ref ); - free( psz_path ); input_item_node_Delete( p_subitems ); return VLC_ENOMEM; } + char *psz_absolute = vlc_uri_resolve( psz_url, psz_ref ); + free( psz_url ); free( psz_ref ); + if( psz_absolute == NULL ) + { + input_item_node_Delete( p_subitems ); + return VLC_ENOMEM; + } psz_ref = psz_absolute; - free( psz_path ); } msg_Dbg( p_demux, "adding ref = `%s'", psz_ref ); input_item_t *p_item = input_item_New( psz_ref, NULL ); -- 2.11.4.GIT