]> git.sesse.net Git - vlc/blobdiff - modules/access/mms/mmsh.c
Replace argument = realloc( argument, size ); with realloc_or_free() in modules/...
[vlc] / modules / access / mms / mmsh.c
index ff66d398853b8e499c346bcf77fc414f2096e976..98784b21b9c461b94a6068a27ada351793557925 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_access.h>
 #include <vlc_strings.h>
 #include <vlc_input.h>
+#include <vlc_memory.h>
 
 #include <vlc_network.h>
 #include <vlc_url.h>
@@ -147,21 +150,14 @@ int MMSHOpen( access_t *p_access )
         ( *p_sys->url.psz_host == '\0' ) )
     {
         msg_Err( p_access, "invalid host" );
-        vlc_UrlClean( &p_sys->proxy );
-        vlc_UrlClean( &p_sys->url );
-        free( p_sys );
-        return VLC_EGENERIC;
+        goto error;
     }
     if( p_sys->url.i_port <= 0 )
         p_sys->url.i_port = 80;
 
     if( Describe( p_access, &psz_location ) )
-    {
-        vlc_UrlClean( &p_sys->proxy );
-        vlc_UrlClean( &p_sys->url );
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
+
     /* Handle redirection */
     if( psz_location && *psz_location )
     {
@@ -172,11 +168,8 @@ int MMSHOpen( access_t *p_access )
 
         if( !p_input )
         {
-            vlc_UrlClean( &p_sys->proxy );
-            vlc_UrlClean( &p_sys->url );
-            free( p_sys );
             free( psz_location );
-            return VLC_EGENERIC;
+            goto error;
         }
         /** \bug we do not autodelete here */
         p_new_loc = input_item_New( p_access, psz_location, psz_location );
@@ -197,10 +190,7 @@ int MMSHOpen( access_t *p_access )
     {
         msg_Err( p_access, "cannot start stream" );
         free( p_sys->p_header );
-        vlc_UrlClean( &p_sys->proxy );
-        vlc_UrlClean( &p_sys->url );
-        free( p_sys );
-        return VLC_EGENERIC;
+        goto error;
     }
 
     if( !p_sys->b_broadcast )
@@ -209,6 +199,12 @@ int MMSHOpen( access_t *p_access )
     }
 
     return VLC_SUCCESS;
+
+error:
+    vlc_UrlClean( &p_sys->proxy );
+    vlc_UrlClean( &p_sys->url );
+    free( p_sys );
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -220,7 +216,7 @@ void  MMSHClose ( access_t *p_access )
 
     Stop( p_access );
 
-    free( p_sys->p_header  );
+    free( p_sys->p_header );
 
     vlc_UrlClean( &p_sys->proxy );
     vlc_UrlClean( &p_sys->url );
@@ -435,6 +431,8 @@ static int Restart( access_t *p_access )
         msg_Err( p_access, "describe failed" );
         return VLC_EGENERIC;
     }
+    free( psz_location );
+
     /* */
     if( Start( p_access, 0 ) )
     {
@@ -679,6 +677,7 @@ static int Describe( access_t  *p_access, char **ppsz_location )
         *ppsz_location = psz_location;
         return VLC_SUCCESS;
     }
+    free( psz_location );
 
     /* Read the asf header */
     GetHeader( p_access );
@@ -738,7 +737,8 @@ static void GetHeader( access_t *p_access )
         if( ck.i_data > 0 )
         {
             p_sys->i_header += ck.i_data;
-            p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header );
+            p_sys->p_header = realloc_or_free( p_sys->p_header, p_sys->i_header );
+            assert( p_sys->p_header );
             memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
                     ck.p_data, ck.i_data );
         }