From 9957b2285c9dc9b279e17ba03f1b269af533429f Mon Sep 17 00:00:00 2001 From: Sigmund Augdal Helberg Date: Fri, 1 Apr 2005 22:23:22 +0000 Subject: [PATCH] fixed a few problems with stream_UrlNew --- include/vlc_stream.h | 2 +- src/input/stream.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/vlc_stream.h b/include/vlc_stream.h index e81a1cd462..84e78034b8 100644 --- a/include/vlc_stream.h +++ b/include/vlc_stream.h @@ -199,7 +199,7 @@ VLC_EXPORT( void, stream_DemuxDelete,( stream_t *s ) ); #define stream_MemoryNew( a, b, c, d ) __stream_MemoryNew( VLC_OBJECT(a), b, c, d ) VLC_EXPORT( stream_t *,__stream_MemoryNew, (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory ) ); #define stream_UrlNew( a, b ) __stream_UrlNew( VLC_OBJECT(a), b ) -VLC_EXPORT( stream_t *,__stream_UrlNew, (vlc_object_t *p_this, char *psz_url ) ); +VLC_EXPORT( stream_t *,__stream_UrlNew, (vlc_object_t *p_this, const char *psz_url ) ); /** * @} diff --git a/src/input/stream.c b/src/input/stream.c index 7e681770d5..6adb86375e 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -188,33 +188,38 @@ static int ASeek( stream_t *s, int64_t i_pos ); /**************************************************************************** * stream_AccessNew: create a stream from a access ****************************************************************************/ -stream_t *__stream_UrlNew( vlc_object_t *p_parent, char *psz_url ) +stream_t *__stream_UrlNew( vlc_object_t *p_parent, const char *psz_url ) { - char *psz_access, *psz_demux, *psz_path; + char *psz_access, *psz_demux, *psz_path, *psz_dup; access_t *p_access; stream_t *p_res; - - MRLSplit( p_parent, psz_url, &psz_access, &psz_demux, &psz_path ); + + psz_dup = strdup( psz_url ); + MRLSplit( p_parent, psz_dup, &psz_access, &psz_demux, &psz_path ); /* Now try a real access */ p_access = access2_New( p_parent, psz_access, NULL, - psz_path, VLC_TRUE ); + psz_path, VLC_FALSE ); if( p_access == NULL ) { msg_Err( p_parent, "no suitable access module for `%s'", psz_url ); + free( psz_dup ); return NULL; } p_res = stream_AccessNew( p_access, VLC_TRUE ); if( p_res ) { p_res->pf_destroy = UStreamDestroy; + free( psz_dup ); return p_res; } else { access2_Delete( p_access ); } + free( psz_dup ); + return NULL; } stream_t *stream_AccessNew( access_t *p_access, vlc_bool_t b_quick ) -- 2.39.2