stream: allow NULL psz_url and fail as appropriate
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 26 Jul 2015 11:12:27 +0000 (14:12 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 26 Jul 2015 12:38:25 +0000 (15:38 +0300)
Previously, "" would be used, leading to nonsensical results in those
stream filters that actually need a URL.

modules/access/archive/stream.c
modules/access/rar/rar.c
modules/access/zip/zipstream.c
modules/demux/image.c
modules/stream_filter/hds/hds.c
modules/stream_filter/smooth/smooth.c
src/input/stream_demux.c
src/input/stream_filter.c
src/input/stream_memory.c

index 8eb0607..4fa1a64 100644 (file)
@@ -169,6 +169,8 @@ int StreamOpen(vlc_object_t *p_object)
 
     if (!ProbeArchiveFormat(p_stream->p_source))
         return VLC_EGENERIC;
+    if (p_stream->psz_url == NULL)
+        return VLC_EGENERIC;
 
     p_stream->p_sys = p_sys = calloc( 1, sizeof( *p_sys ) );
     if( !p_sys )
index 6ef343a..009e4ed 100644 (file)
@@ -317,12 +317,15 @@ int RarParse(stream_t *s, int *count, rar_file_t ***file, unsigned int *pi_nbvol
     *file = NULL;
     *pi_nbvols = 1;
 
+    if( s->psz_url == NULL )
+        return VLC_EGENERIC;
+
     const rar_pattern_t *pattern = FindVolumePattern(s->psz_url, b_extonly);
     int volume_offset = 0;
 
     char *volume_mrl = strdup(s->psz_url);
     if (volume_mrl == NULL)
-        return VLC_EGENERIC;
+        return VLC_ENOMEM;
 
     stream_t *vol = s;
     for (;;) {
index 72aeb5f..88d1e53 100644 (file)
@@ -177,6 +177,8 @@ int StreamOpen( vlc_object_t *p_this )
         return VLC_EGENERIC;
     if( memcmp( p_peek, p_zip_marker, i_zip_marker ) )
         return VLC_EGENERIC;
+    if( s->psz_url == NULL )
+        return VLC_EGENERIC;
 
     s->p_sys = p_sys = calloc( 1, sizeof( *p_sys ) );
     if( !p_sys )
index 5b96605..3676057 100644 (file)
@@ -437,6 +437,9 @@ static bool FindSVGmarker(int *position, const uint8_t *data, const int size, co
 
 static bool IsSVG(stream_t *s)
 {
+    if (s->psz_url == NULL)
+        return false;
+
     char *ext = strstr(s->psz_url, ".svg");
     if (!ext) return false;
 
index 8f0f21a..98074a4 100644 (file)
@@ -1628,7 +1628,7 @@ static int Open( vlc_object_t *p_this )
     stream_t *s = (stream_t*)p_this;
     stream_sys_t *p_sys;
 
-    if( !isHDS( s ) )
+    if( !isHDS( s ) || s->psz_url == NULL )
         return VLC_EGENERIC;
 
     msg_Info( p_this, "HTTP Dynamic Streaming (%s)", s->psz_url );
index dfac375..6faa4a1 100644 (file)
@@ -459,7 +459,7 @@ static int Open( vlc_object_t *p_this )
     stream_t *s = (stream_t*)p_this;
     stream_sys_t *p_sys;
 
-    if( !isSmoothStreaming( s ) )
+    if( !isSmoothStreaming( s ) || s->psz_url == NULL )
         return VLC_EGENERIC;
 
     msg_Info( p_this, "Smooth Streaming (%s)", s->psz_url );
index e122cbc..21df46b 100644 (file)
@@ -74,13 +74,12 @@ stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *ou
     if( s == NULL )
         return NULL;
     s->p_input = p_demux->p_input;
-    s->psz_url   = strdup(""); /* N/A */
     s->pf_read   = DStreamRead;
     s->pf_control= DStreamControl;
     s->pf_destroy= DStreamDelete;
 
     s->p_sys = p_sys = malloc( sizeof( *p_sys) );
-    if( !s->psz_url || !s->p_sys )
+    if( !s->p_sys )
     {
         free( p_sys );
         stream_CommonDelete( s );
index 5cb57f7..0e3cf4b 100644 (file)
@@ -48,12 +48,14 @@ stream_t *stream_FilterNew( stream_t *p_source,
 
     s->p_input = p_source->p_input;
 
-    /* */
-    s->psz_url = strdup( p_source->psz_url );
-    if( unlikely(s->psz_url == NULL) )
+    if( s->psz_url != NULL )
     {
-        stream_CommonDelete( s );
-        return NULL;
+        s->psz_url = strdup( p_source->psz_url );
+        if( unlikely(s->psz_url == NULL) )
+        {
+            stream_CommonDelete( s );
+            return NULL;
+        }
     }
     s->p_source = p_source;
 
index 219a155..eb6e6f3 100644 (file)
@@ -59,9 +59,8 @@ stream_t *stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
     if( !s )
         return NULL;
 
-    s->psz_url = strdup( "" ); /* N/A */
     s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
-    if( !s->psz_url || !s->p_sys )
+    if( !s->p_sys )
     {
         stream_CommonDelete( s );
         free( p_sys );