[vlc-commits] mp4: use vlc_uri_resolve()

Rémi Denis-Courmont git at videolan.org
Sat Dec 2 22:26:47 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec  2 22:49:21 2017 +0200| [50991f02d498a92d4e5441cc0c79cd293e92d69e] | committer: Rémi Denis-Courmont

mp4: use vlc_uri_resolve()

(Also remove NULL deference on error.)

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

 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 <vlc_aout.h>
 #include <vlc_plugin.h>
 #include <vlc_dialog.h>
+#include <vlc_url.h>
 #include <assert.h>
 #include <limits.h>
 #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 );



More information about the vlc-commits mailing list