Do not leak psz_demux
authorRafaël Carré <funman@videolan.org>
Fri, 9 May 2008 21:11:52 +0000 (23:11 +0200)
committerRafaël Carré <funman@videolan.org>
Fri, 9 May 2008 21:11:52 +0000 (23:11 +0200)
modules/access/directory.c
modules/access/dshow/dshow.cpp
modules/access/dv.c
modules/access/http.c
modules/access/udp.c
modules/access/vcd/vcd.c
modules/access/vcdx/access.c

index c2a98ec..d770321 100644 (file)
@@ -166,6 +166,7 @@ static int Open( vlc_object_t *p_this )
     p_access->pf_control= Control;
 
     /* Force a demux */
+    free( p_access->psz_demux );
     p_access->psz_demux = strdup( "directory" );
 
     return VLC_SUCCESS;
index 8ce9064..ee28b86 100644 (file)
@@ -657,11 +657,13 @@ static int AccessOpen( vlc_object_t *p_this )
             p_stream->i_fourcc == VLC_FOURCC('d','v','s','d') ||
             p_stream->i_fourcc == VLC_FOURCC('d','v','h','d') )
         {
+            free( p_access->psz_demux );
             p_access->psz_demux = strdup( "rawdv" );
         }
         else if( p_stream->i_fourcc == VLC_FOURCC('m','p','2','v') )
         {
-            p_access->psz_demux = "mpgv";
+            free( p_access->psz_demux );
+            p_access->psz_demux = strdup( "mpgv" );
         }
     }
 
index 90c6a9f..d0d962e 100644 (file)
@@ -340,8 +340,13 @@ static block_t *Block( access_t *p_access )
     access_sys_t *p_sys = p_access->p_sys;
     block_t *p_block = NULL;
 
-//     if( !p_access->psz_demux )
-//         p_access->psz_demux = strdup( "rawdv" );
+#if 0
+    if( !p_access->psz_demux )
+    {
+        free( p_access->psz_demux );
+        p_access->psz_demux = strdup( "rawdv" );
+    }
+#endif
 
     vlc_mutex_lock( &p_sys->lock );
     p_block = p_sys->p_frame;
index d8715c5..d90f01f 100644 (file)
@@ -454,12 +454,21 @@ connect:
         {
             if( !strcasecmp( p_sys->psz_mime, "video/nsv" ) ||
                 !strcasecmp( p_sys->psz_mime, "video/nsa" ) )
+            {
+                free( p_access->psz_demux );
                 p_access->psz_demux = strdup( "nsv" );
+            }
             else if( !strcasecmp( p_sys->psz_mime, "audio/aac" ) ||
                      !strcasecmp( p_sys->psz_mime, "audio/aacp" ) )
+            {
+                free( p_access->psz_demux );
                 p_access->psz_demux = strdup( "m4a" );
+            }
             else if( !strcasecmp( p_sys->psz_mime, "audio/mpeg" ) )
+            {
+                free( p_access->psz_demux );
                 p_access->psz_demux = strdup( "mp3" );
+            }
 
             msg_Info( p_access, "Raw-audio server found, %s demuxer selected",
                       p_access->psz_demux );
@@ -472,8 +481,9 @@ connect:
         }
         else if( !p_sys->psz_mime )
         {
-             /* Shoutcast */
-             p_access->psz_demux = strdup( "mp3" );
+            free( p_access->psz_demux );
+            /* Shoutcast */
+            p_access->psz_demux = strdup( "mp3" );
         }
         /* else probably Ogg Vorbis */
     }
@@ -481,17 +491,22 @@ connect:
              p_sys->psz_mime &&
              !strcasecmp( p_sys->psz_mime, "misc/ultravox" ) )
     {
+        free( p_access->psz_demux );
         /* Grrrr! detect ultravox server and force NSV demuxer */
         p_access->psz_demux = strdup( "nsv" );
     }
     else if( !strcmp( p_access->psz_access, "itpc" ) )
     {
+        free( p_access->psz_demux );
         p_access->psz_demux = strdup( "podcast" );
     }
     else if( p_sys->psz_mime &&
              !strncasecmp( p_sys->psz_mime, "application/xspf+xml", 20 ) &&
              ( memchr( " ;\t", p_sys->psz_mime[20], 4 ) != NULL ) )
+    {
+        free( p_access->psz_demux );
         p_access->psz_demux = strdup( "xspf-open" );
+    }
 
     if( p_sys->b_reconnect ) msg_Dbg( p_access, "auto re-connect enabled" );
 
index b2c877f..24a4731 100644 (file)
@@ -743,16 +743,19 @@ static block_t *BlockChoose( access_t *p_access )
     {
         case 33:
             msg_Dbg( p_access, "detected MPEG2 TS over RTP" );
+            free( p_access->psz_demux );
             p_access->psz_demux = strdup( "ts" );
             break;
 
         case 14:
             msg_Dbg( p_access, "detected MPEG Audio over RTP" );
+            free( p_access->psz_demux );
             p_access->psz_demux = strdup( "mpga" );
             break;
 
         case 32:
             msg_Dbg( p_access, "detected MPEG Video over RTP" );
+            free( p_access->psz_demux );
             p_access->psz_demux = strdup( "mpgv" );
             break;
 
index f42320b..854fbad 100644 (file)
@@ -211,6 +211,7 @@ static int Open( vlc_object_t *p_this )
     p_access->info.i_pos = ( p_sys->i_sector - p_sys->p_sectors[1+i_title] ) *
         VCD_DATA_SIZE;
 
+    free( p_access->psz_demux );
     p_access->psz_demux = strdup( "ps" );
 
     return VLC_SUCCESS;
index c54d6d1..0509cd7 100644 (file)
@@ -957,6 +957,7 @@ VCDOpen ( vlc_object_t *p_this )
 
     vcdplayer_play( p_access, itemid );
 
+    free( p_access->psz_demux );
     p_access->psz_demux = strdup( "ps" );
 
 #if FIXED