]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/asx.c
Replace argument = realloc( argument, size ); with realloc_or_free() in modules/...
[vlc] / modules / demux / playlist / asx.c
index 4f990706a93945b6865cf0c16d4561b95690cc96..b996b7e0e3be0cc9f38f17345fbdded2513cb5c2 100644 (file)
@@ -31,6 +31,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_demux.h>
 
@@ -38,6 +40,7 @@
 #include <vlc_charset.h>
 #include "playlist.h"
 #include <vlc_meta.h>
+#include <vlc_memory.h>
 
 struct demux_sys_t
 {
@@ -243,6 +246,7 @@ static int Demux( demux_t *p_demux )
         p_sys->i_data_len = stream_Size( p_demux->s ) + 1; /* This is a cheat to prevent unnecessary realloc */
         if( p_sys->i_data_len <= 0 || p_sys->i_data_len > 16384 ) p_sys->i_data_len = 1024;
         p_sys->psz_data = malloc( p_sys->i_data_len +1);
+        assert( p_sys->psz_data );
 
         /* load the complete file */
         for( ;; )
@@ -254,7 +258,9 @@ static int Demux( demux_t *p_demux )
 
             i_pos += i_read;
             p_sys->i_data_len <<= 1 ;
-            p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) + 1 );
+            p_sys->psz_data = realloc_or_free( p_sys->psz_data,
+                                   p_sys->i_data_len * sizeof( char * ) + 1 );
+            assert( p_sys->psz_data );
         }
         if( p_sys->i_data_len <= 0 ) return -1;
     }
@@ -313,6 +319,7 @@ static int Demux( demux_t *p_demux )
                             if( i_strlen < 1 ) continue;
                             msg_Dbg( p_demux, "param name strlen: %d", i_strlen);
                             psz_string = malloc( i_strlen + 1);
+                            assert( psz_string );
                             memcpy( psz_string, psz_backup, i_strlen );
                             psz_string[i_strlen] = '\0';
                             msg_Dbg( p_demux, "param name: %s", psz_string);
@@ -335,6 +342,7 @@ static int Demux( demux_t *p_demux )
                             if( i_strlen < 1 ) continue;
                             msg_Dbg( p_demux, "param value strlen: %d", i_strlen);
                             psz_string = malloc( i_strlen +1);
+                            assert( psz_string );
                             memcpy( psz_string, psz_backup, i_strlen );
                             psz_string[i_strlen] = '\0';
                             msg_Dbg( p_demux, "param value: %s", psz_string);
@@ -460,6 +468,7 @@ static int Demux( demux_t *p_demux )
                             i_strlen = psz_parse-psz_backup;
                             if( i_strlen < 1 ) continue;
                             psz_string = malloc( i_strlen +1);
+                            assert( psz_string );
                             memcpy( psz_string, psz_backup, i_strlen );
                             psz_string[i_strlen] = '\0';
                             input_item_t *p_input;
@@ -632,6 +641,7 @@ static int Demux( demux_t *p_demux )
 
                             free( psz_href );
                             psz_href = malloc( i_strlen +1);
+                            assert( psz_string );
                             memcpy( psz_href, psz_backup, i_strlen );
                             psz_href[i_strlen] = '\0';
                             psz_tmp = psz_href + (i_strlen-1);