]> git.sesse.net Git - vlc/blobdiff - modules/control/http/macro.c
Replace argument = realloc( argument, size ); with realloc_or_free() in modules/...
[vlc] / modules / control / http / macro.c
index 4262d22f56d439954db93b6b1aebc6857c032867..fb2802b706af705f8889f7df6a56849d299f02d5 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include "http.h"
 #include "macros.h"
 #include <vlc_url.h>
+#include <vlc_memory.h>
 
 static int MacroParse( macro_t *m, char *psz_src )
 {
@@ -149,7 +152,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
     {               \
         int __i__ = *pp_dst - *pp_data; \
         *pi_data += (l);                  \
-        *pp_data = realloc( *pp_data, *pi_data );   \
+        *pp_data = realloc_or_free( *pp_data, *pi_data );   \
+        assert( *pp_data ); \
         *pp_dst = (*pp_data) + __i__;   \
     }
 #define PRINT( str ) \
@@ -365,8 +369,9 @@ static void MacroDo( httpd_file_sys_t *p_args,
                         if( !*item ) continue;
 
                         int i_item = atoi( item );
-                        p_items = realloc( p_items, (i_nb_items + 1) *
-                                           sizeof(*p_items) );
+                        p_items = realloc_or_free( p_items,
+                                        (i_nb_items + 1) * sizeof(*p_items) );
+                        assert( p_items );
                         p_items[i_nb_items] = i_item;
                         i_nb_items++;
                     }
@@ -402,8 +407,9 @@ static void MacroDo( httpd_file_sys_t *p_args,
                         if( !*item ) continue;
 
                         int i_item = atoi( item );
-                        p_items = realloc( p_items, (i_nb_items + 1) *
-                                           sizeof(*p_items) );
+                        p_items = realloc_or_free( p_items,
+                                        (i_nb_items + 1) * sizeof(*p_items) );
+                        assert( p_items );
                         p_items[i_nb_items] = i_item;
                         i_nb_items++;
                     }
@@ -548,6 +554,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
                     char *vlm_error;
                     int i;
 
+                    assert( psz );
+
                     if( p_intf->p_sys->p_vlm == NULL )
                         p_intf->p_sys->p_vlm = vlm_New( p_intf );
 
@@ -880,6 +888,8 @@ void Execute( httpd_file_sys_t *p_args,
     src = dup = malloc( _end - _src + 1 );
     end = src +( _end - _src );
 
+    assert( src );
+
     memcpy( src, _src, _end - _src );
     *end = '\0';
 
@@ -1118,7 +1128,8 @@ void Execute( httpd_file_sys_t *p_args,
             int i_index = dst - *pp_data;
 
             *pi_data += i_copy;
-            *pp_data = realloc( *pp_data, *pi_data );
+            *pp_data = realloc_or_free( *pp_data, *pi_data );
+            assert( *pp_data );
             dst = (*pp_data) + i_index;
 
             memcpy( dst, src, i_copy );