]> git.sesse.net Git - vlc/commitdiff
modules/misc/sap.c:
authorSigmund Augdal Helberg <sigmunau@videolan.org>
Mon, 23 Feb 2004 21:00:37 +0000 (21:00 +0000)
committerSigmund Augdal Helberg <sigmunau@videolan.org>
Mon, 23 Feb 2004 21:00:37 +0000 (21:00 +0000)
 * fixed two memleaks, one of them rather large
 * fix for http announces that don't start the filename part with '/'

modules/misc/sap.c

index f51503417d83572f3dd918e9bc3f3a9fa6751b50..48c479085fbe5ba9cf9bf010eff1f343934224a8 100644 (file)
@@ -2,7 +2,7 @@
  * sap.c :  SAP interface module
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: sap.c,v 1.52 2004/01/29 17:51:08 zorglub Exp $
+ * $Id: sap.c,v 1.53 2004/02/23 21:00:37 sigmunau Exp $
  *
  * Authors: Arnaud Schauly <gitan@via.ecp.fr>
  *          ClĂ©ment Stenac <zorglub@via.ecp.fr>
@@ -362,6 +362,7 @@ static void Close( vlc_object_t *p_this )
            free( p_sys->pp_announces[i]->psz_uri );
         free( p_sys->pp_announces[i] );
     }
+    free( p_sys->pp_announces );
 
     free( p_sys );
 }
@@ -805,12 +806,16 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
             {
                 psz_http_path = strdup( "/" );
             }
-
-            psz_item_uri = malloc( strlen( psz_proto ) + strlen( psz_uri ) +
-                                   strlen( psz_port ) + strlen(psz_http_path) +
-                                    5 );
-            sprintf( psz_item_uri, "%s://%s:%s%s", psz_proto,
-                            psz_uri, psz_port,psz_http_path );
+            if( *psz_http_path == '/' )
+            {
+                asprintf( &psz_item_uri, "%s://%s:%s%s", psz_proto,
+                         psz_uri, psz_port,psz_http_path );
+            }
+            else
+            {
+                asprintf( &psz_item_uri, "%s://%s:%s/%s", psz_proto, psz_uri,
+                          psz_port, psz_http_path );
+            }
 
             if( psz_http_path )
             {
@@ -855,6 +860,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
 
                     vlc_object_release( p_playlist );
                 }
+                free( psz_item_uri );
                 return;
             }
         }