]> git.sesse.net Git - vlc/commitdiff
Replace argument = realloc( argument, size ); with realloc_or_free() in modules/...
authorJP Dinger <jpd@videolan.org>
Sat, 5 Dec 2009 14:24:19 +0000 (15:24 +0100)
committerJP Dinger <jpd@videolan.org>
Sat, 5 Dec 2009 21:25:43 +0000 (22:25 +0100)
63 files changed:
modules/access/dshow/dshow.cpp
modules/access/dvb/en50221.c
modules/access/jack.c
modules/access/mms/buffer.c
modules/access/mms/mmsh.c
modules/access/mms/mmstu.c
modules/access/rtsp/real.c
modules/access_output/http.c
modules/audio_filter/converter/dtstospdif.c
modules/audio_output/alsa.c
modules/audio_output/waveout.c
modules/codec/cmml/history.c
modules/codec/cmml/xarray.c
modules/codec/cmml/xurl.c
modules/codec/dvbsub.c
modules/codec/flac.c
modules/codec/kate.c
modules/codec/quicktime.c
modules/codec/realvideo.c
modules/codec/speex.c
modules/codec/subtitles/subsdec.c
modules/codec/subtitles/subsusf.c
modules/codec/theora.c
modules/codec/vorbis.c
modules/control/http/macro.c
modules/control/http/mvar.c
modules/control/http/util.c
modules/control/rc.c
modules/control/telnet.c
modules/demux/asademux.c
modules/demux/avi/avi.c
modules/demux/gme.cpp
modules/demux/live555.cpp
modules/demux/mkv/chapters.cpp
modules/demux/mkv/matroska_segment.cpp
modules/demux/nuv.c
modules/demux/ogg.c
modules/demux/playlist/asx.c
modules/demux/ps.h
modules/demux/subtitle.c
modules/demux/subtitle_asa.c
modules/demux/ts.c
modules/demux/vobsub.c
modules/gui/qnx/vout.c
modules/misc/freetype.c
modules/misc/text_renderer.h
modules/misc/xml/xtag.c
modules/mux/avi.c
modules/mux/mp4.c
modules/mux/ogg.c
modules/packetizer/mpeg4video.c
modules/packetizer/vc1.c
modules/services_discovery/sap.c
modules/stream_out/bridge.c
modules/stream_out/mosaic_bridge.c
modules/stream_out/raop.c
modules/video_filter/audiobargraph_v.c
modules/video_filter/bluescreen.c
modules/video_filter/dynamicoverlay/dynamicoverlay_list.c
modules/video_filter/gaussianblur.c
modules/video_filter/mosaic.c
modules/video_filter/rss.c
modules/video_output/msw/directx.c

index b965bcd3d8e3a730e0afa3ee44f2fbd909d47fb4..bcdcda831e05d4a34d17b4a82e7cae11bf7b6830 100644 (file)
@@ -34,6 +34,8 @@
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_input.h>
@@ -41,6 +43,7 @@
 #include <vlc_demux.h>
 #include <vlc_dialog.h>
 #include <vlc_charset.h>
+#include <vlc_memory.h>
 
 #include "common.h"
 #include "filter.h"
@@ -1101,8 +1104,9 @@ static int OpenDevice( vlc_object_t *p_this, access_sys_t *p_sys,
             dshow_stream.p_device_filter = p_device_filter;
             dshow_stream.p_capture_filter = p_capture_filter;
 
-            p_sys->pp_streams = (dshow_stream_t **)realloc( p_sys->pp_streams,
+            p_sys->pp_streams = realloc_or_free( p_sys->pp_streams,
                 sizeof(dshow_stream_t *) * (p_sys->i_streams + 1) );
+            assert( p_sys->pp_streams );
             p_sys->pp_streams[p_sys->i_streams] = new dshow_stream_t;
             *p_sys->pp_streams[p_sys->i_streams++] = dshow_stream;
 
@@ -1963,12 +1967,12 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
 
     if( !list_devices.size() ) return VLC_SUCCESS;
 
-    p_item->ppsz_list =
-        (char **)realloc( p_item->ppsz_list,
+    p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
                           (list_devices.size()+3) * sizeof(char *) );
-    p_item->ppsz_list_text =
-        (char **)realloc( p_item->ppsz_list_text,
+    assert( p_item->ppsz_list );
+    p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
                           (list_devices.size()+3) * sizeof(char *) );
+    assert( p_item->ppsz_list_text );
 
     list<string>::iterator iter;
     for( iter = list_devices.begin(), i = 2; iter != list_devices.end();
index 2f16fd47007611c3b81b093a20252f454eddd174..d17a24aa84393af3b8cd5f97fad3e26b78ed50bf 100644 (file)
@@ -273,6 +273,7 @@ static int TPDURecv( access_t * p_access, uint8_t i_slot, uint8_t *pi_tag,
     if ( pi_size == NULL )
     {
         p_data = malloc( MAX_TPDU_SIZE );
+        assert( p_data );
     }
 
     for ( ; ; )
@@ -358,6 +359,8 @@ static int SPDUSend( access_t * p_access, int i_session_id,
     uint8_t i_tag;
     uint8_t i_slot = p_sys->p_sessions[i_session_id - 1].i_slot;
 
+    assert( p_spdu );
+
     *p++ = ST_SESSION_NUMBER;
     *p++ = 0x02;
     *p++ = (i_session_id >> 8);
@@ -806,6 +809,8 @@ static int APDUSend( access_t * p_access, int i_session_id, int i_tag,
     ca_msg_t ca_msg;
     int i_ret;
 
+    assert( p_apdu );
+
     *p++ = (i_tag >> 16);
     *p++ = (i_tag >> 8) & 0xff;
     *p++ = i_tag & 0xff;
@@ -1051,6 +1056,8 @@ static uint8_t *CAPMTHeader( system_ids_t *p_ids, uint8_t i_list_mgt,
     else
         p_data = malloc( 6 );
 
+    assert( p_data );
+
     p_data[0] = i_list_mgt;
     p_data[1] = i_program_number >> 8;
     p_data[2] = i_program_number & 0xff;
@@ -1105,6 +1112,8 @@ static uint8_t *CAPMTES( system_ids_t *p_ids, uint8_t *p_capmt,
     else
         p_data = realloc( p_capmt, i_capmt_size + 5 );
 
+    assert( p_data );
+
     i = i_capmt_size;
 
     p_data[i] = i_type;
@@ -1573,6 +1582,7 @@ static void MMISendObject( access_t *p_access, int i_session_id,
         i_tag = AOT_ANSW;
         i_size = 1 + strlen( p_object->u.answ.psz_answ );
         p_data = malloc( i_size );
+        assert( p_data );
         p_data[0] = (p_object->u.answ.b_ok == true) ? 0x1 : 0x0;
         strncpy( (char *)&p_data[1], p_object->u.answ.psz_answ, i_size - 1 );
         break;
@@ -1581,6 +1591,7 @@ static void MMISendObject( access_t *p_access, int i_session_id,
         i_tag = AOT_MENU_ANSW;
         i_size = 1;
         p_data = malloc( i_size );
+        assert( p_data );
         p_data[0] = p_object->u.menu_answ.i_choice;
         break;
 
@@ -1667,6 +1678,7 @@ static void MMIHandleEnq( access_t *p_access, int i_session_id,
     d += 2; /* skip answer_text_length because it is not mandatory */
     l -= 2;
     p_mmi->last_object.u.enq.psz_text = malloc( l + 1 );
+    assert( p_mmi->last_object.u.enq.psz_text );
     strncpy( p_mmi->last_object.u.enq.psz_text, (char *)d, l );
     p_mmi->last_object.u.enq.psz_text[l] = '\0';
 
@@ -1810,6 +1822,7 @@ static void MMIOpen( access_t *p_access, int i_session_id )
     p_sys->p_sessions[i_session_id - 1].pf_close = MMIClose;
     p_sys->p_sessions[i_session_id - 1].p_sys = malloc(sizeof(mmi_t));
     p_mmi = (mmi_t *)p_sys->p_sessions[i_session_id - 1].p_sys;
+    assert( p_mmi );
     p_mmi->last_object.i_object_type = EN50221_MMI_NONE;
 }
 
@@ -2440,6 +2453,7 @@ char *dvbsi_to_utf8( const char *psz_instring, size_t i_length )
     i_in = i_length - (psz_stringstart - psz_instring );
     i_out = i_in * 6;
     psz_outstring = psz_tmp = (char*)malloc( i_out + 1 );
+    assert( psz_outstring );
     vlc_iconv( iconv_handle, &psz_stringstart, &i_in, &psz_tmp, &i_out );
     vlc_iconv_close( iconv_handle );
     *psz_tmp = '\0';
index 0ff2a818341380e8c34839f796786927c7da8161..fbbac2d08da962957a0f861b0b412f691021476f 100644 (file)
@@ -543,6 +543,7 @@ static void Port_finder( demux_t *p_demux )
             /* alloc an array to store all the matched ports */
             p_sys->pp_jack_port_table = realloc( p_sys->pp_jack_port_table,
                 (i_out_ports * sizeof( char * ) + i_total_out_ports * sizeof( char * ) ) );
+            assert( p_sys->pp_jack_port_table );
 
             for(int i=0; i<i_out_ports;i++)
             {
index 06115d35f1e1e259593fecc6ab1332ffc4b7dfac..1cc4877623d2ec828d1edd92c739c3b7c573f010 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
+#include <vlc_memory.h>
 
 #include "asf.h"
 #include "buffer.h"
@@ -41,11 +44,8 @@ int var_buffer_initwrite( var_buffer_t *p_buf, int i_default_size )
 {
     p_buf->i_size =  ( i_default_size > 0 ) ? i_default_size : 2048;
     p_buf->i_data = 0;
-    if( !( p_buf->p_data = malloc( p_buf->i_size ) ) )
-    {
-        return( -1 );
-    }
-    return( 0 );
+    p_buf->p_data = malloc( p_buf->i_size );
+    return p_buf->p_data ? 0 : -1;
 }
 
 int var_buffer_reinitwrite( var_buffer_t *p_buf, int i_default_size )
@@ -62,11 +62,7 @@ int var_buffer_reinitwrite( var_buffer_t *p_buf, int i_default_size )
         p_buf->i_size =  ( i_default_size > 0 ) ? i_default_size : 2048;
         p_buf->p_data = malloc( p_buf->i_size );
     }
-    if( !p_buf->p_data )
-    {
-        return( -1 );
-    }
-    return( 0 );
+    return p_buf->p_data ? 0 : -1;
 }
 
 void var_buffer_add8 ( var_buffer_t *p_buf, uint8_t  i_byte )
@@ -75,7 +71,8 @@ void var_buffer_add8 ( var_buffer_t *p_buf, uint8_t  i_byte )
     if( p_buf->i_data >= p_buf->i_size )
     {
         p_buf->i_size += 1024;
-        p_buf->p_data = realloc( p_buf->p_data, p_buf->i_size );
+        p_buf->p_data = realloc_or_free( p_buf->p_data, p_buf->i_size );
+        assert( p_buf->p_data );
     }
     p_buf->p_data[p_buf->i_data] = i_byte&0xff;
     p_buf->i_data++;
@@ -105,12 +102,11 @@ void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem )
     if( p_buf->i_data + i_mem >= p_buf->i_size )
     {
         p_buf->i_size += i_mem + 1024;
-        p_buf->p_data = realloc( p_buf->p_data, p_buf->i_size );
+        p_buf->p_data = realloc_or_free( p_buf->p_data, p_buf->i_size );
+        assert( p_buf->p_data );
     }
 
-    memcpy( p_buf->p_data + p_buf->i_data,
-            p_mem,
-            i_mem );
+    memcpy( p_buf->p_data + p_buf->i_data, p_mem, i_mem );
     p_buf->i_data += i_mem;
 }
 
@@ -129,6 +125,7 @@ void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str )
         char *psz_out, *psz_tmp;
 
         psz_out = psz_tmp = malloc( i_out + 1 );
+        assert( psz_out );
         iconv_handle = vlc_iconv_open( "UTF-16LE", "UTF-8" );
         vlc_iconv( iconv_handle, &p_str, &i_in, &psz_tmp, &i_out );
         vlc_iconv_close( iconv_handle );
index 688ad524bca261dbf8a7bdb7505c01c7fbd04588..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>
@@ -734,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 );
         }
index c3277220e366591e12720c92fc4390ce04aeb378..89a772aefc1eeba2e41798d339bac902ab522f3c 100644 (file)
@@ -604,6 +604,7 @@ static int MMSOpen( access_t  *p_access, vlc_url_t *p_url, int  i_proto )
     { \
         int i; \
         psz = malloc( size + 1); \
+        assert( psz ); \
         for( i = 0; i < size; i++ ) \
         { \
             psz[i] = p[i]; \
@@ -1186,6 +1187,7 @@ static int  mms_ParseCommand( access_t *p_access,
     free( p_sys->p_cmd );
     p_sys->i_cmd = i_data;
     p_sys->p_cmd = malloc( i_data );
+    assert( p_sys->p_cmd );
     memcpy( p_sys->p_cmd, p_data, i_data );
 
     *pi_used = i_data; /* by default */
@@ -1308,8 +1310,9 @@ static int  mms_ParsePacket( access_t *p_access,
     {
         if( p_sys->p_header )
         {
-            p_sys->p_header = realloc( p_sys->p_header,
-                                          p_sys->i_header + i_packet_length - 8 );
+            p_sys->p_header = realloc_or_free( p_sys->p_header,
+                                      p_sys->i_header + i_packet_length - 8 );
+            assert( p_sys->p_header );
             memcpy( &p_sys->p_header[p_sys->i_header],
                     p_data + 8, i_packet_length - 8 );
             p_sys->i_header += i_packet_length - 8;
@@ -1318,6 +1321,7 @@ static int  mms_ParsePacket( access_t *p_access,
         else
         {
             uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
+            assert( p_packet );
             memcpy( p_packet, p_data + 8, i_packet_length - 8 );
             p_sys->p_header = p_packet;
             p_sys->i_header = i_packet_length - 8;
@@ -1331,6 +1335,7 @@ static int  mms_ParsePacket( access_t *p_access,
     else
     {
         uint8_t* p_packet = malloc( i_packet_length - 8 ); // don't bother with preheader
+        assert( p_packet );
         memcpy( p_packet, p_data + 8, i_packet_length - 8 );
         FREENULL( p_sys->p_media );
         p_sys->p_media = p_packet;
index d70e111dae6f056443ab4df4528523e28b05a21f..9bd4c87d65ea9a52a0a3073a437ace8b49f48388 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 
 #include <vlc_common.h>
+#include <vlc_memory.h>
 
 #include "rtsp.h"
 #include "real.h"
@@ -49,15 +50,6 @@ static const unsigned char xor_table[] = {
 #define LE_32C(x,y) do {uint32_t in=y; *(uint32_t *)(x)=GetDWLE(&in);} while(0)
 #define MAX(x,y) ((x>y) ? x : y)
 
-/* XXX find a better place for this */
-static inline void *realloc_(void *p, size_t sz)
-{
-    void *n = realloc(p, sz);
-    if( !n )
-        free(p);
-    return n;
-}
-
 static void hash(char *field, char *param)
 {
   uint32_t a, b, c, d;
@@ -698,27 +690,27 @@ rmff_header_t  *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
 
   /* setup our streams */
   real_calc_response_and_checksum (challenge2, checksum, challenge1);
-  buf = realloc_(buf, strlen(challenge2) + strlen(checksum) + 32);
+  buf = realloc_or_free(buf, strlen(challenge2) + strlen(checksum) + 32);
   if( !buf ) goto error;
   sprintf(buf, "RealChallenge2: %s, sd=%s", challenge2, checksum);
   rtsp_schedule_field(rtsp_session, buf);
-  buf = realloc_(buf, strlen(session_id) + 32);
+  buf = realloc_or_free(buf, strlen(session_id) + 32);
   if( !buf ) goto error;
   sprintf(buf, "If-Match: %s", session_id);
   rtsp_schedule_field(rtsp_session, buf);
   rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
-  buf = realloc_(buf, strlen(mrl) + 32);
+  buf = realloc_or_free(buf, strlen(mrl) + 32);
   if( !buf ) goto error;
   sprintf(buf, "%s/streamid=0", mrl);
   rtsp_request_setup(rtsp_session,buf);
 
   if (h->prop->num_streams > 1) {
     rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
-    buf = realloc_(buf, strlen(session_id) + 32);
+    buf = realloc_or_free(buf, strlen(session_id) + 32);
     if( !buf ) goto error;
     sprintf(buf, "If-Match: %s", session_id);
     rtsp_schedule_field(rtsp_session, buf);
-    buf = realloc_(buf, strlen(mrl) + 32);
+    buf = realloc_or_free(buf, strlen(mrl) + 32);
     if( !buf ) goto error;
     sprintf(buf, "%s/streamid=1", mrl);
     rtsp_request_setup(rtsp_session,buf);
index f0e120dc628a5a3b10ab3dc6587c6d88b0729132..b45ffe06744ebc3824bebbbbffc41df53d7762b9 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
-
-
 #include <vlc_input.h>
 #include <vlc_playlist.h>
+#include <vlc_memory.h>
 
 #if 0 //def HAVE_AVAHI_CLIENT
     #include "bonjour.h"
@@ -319,11 +320,16 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_header_size      = 0;
     p_sys->p_header           = malloc( p_sys->i_header_allocated );
     p_sys->b_header_complete  = false;
+    if( !p_sys->p_header )
+        p_sys->i_header_allocated = 0;
 
     p_access->pf_write       = Write;
     p_access->pf_seek        = Seek;
     p_access->pf_control     = Control;
 
+    /* XXX Do we deal gracefully with p_sys->p_header == NULL? */
+    assert( p_sys->p_header );
+
     return VLC_SUCCESS;
 }
 
@@ -393,8 +399,9 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
             {
                 p_sys->i_header_allocated =
                     p_buffer->i_buffer + p_sys->i_header_size + 1024;
-                p_sys->p_header =
-                    realloc( p_sys->p_header, p_sys->i_header_allocated );
+                p_sys->p_header = realloc_or_free( p_sys->p_header,
+                                                  p_sys->i_header_allocated );
+                assert( p_sys->p_header );
             }
             memcpy( &p_sys->p_header[p_sys->i_header_size],
                     p_buffer->p_buffer,
index 7d62c6d178c6c255535989f72dc47a4c695287c1..49a61e82e1c8bb889ffb3dbb02760abf807f4292 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 
 #include <vlc_aout.h>
 #include <vlc_filter.h>
 
+#include <vlc_memory.h>
+
 /*****************************************************************************
  * Local structures
  *****************************************************************************/
@@ -125,8 +129,9 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
                   p_filter->p_sys->i_frame_size, p_in_buf->i_buffer );
 
         p_filter->p_sys->i_frame_size = p_in_buf->i_buffer;
-        p_filter->p_sys->p_buf = realloc( p_filter->p_sys->p_buf,
-                                          p_in_buf->i_buffer * 3 );
+        p_filter->p_sys->p_buf = realloc_or_free( p_filter->p_sys->p_buf,
+                                                  p_in_buf->i_buffer * 3 );
+        assert( p_filter->p_sys->p_buf );
         p_filter->p_sys->i_frames = 0;
     }
 
index e4eaf8b30eebb85293472da5c7c725d1a5f02d24..84e3fd5e7f94e2087bd7805e8731cd207b05c649 100644 (file)
@@ -31,6 +31,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 
@@ -40,6 +42,8 @@
 #include <vlc_aout.h>
 #include <vlc_cpu.h>
 
+#include <vlc_memory.h>
+
 /* ALSA part
    Note: we use the new API which is available since 0.9.0beta10a. */
 #define ALSA_PCM_NEW_HW_PARAMS_API
@@ -1000,12 +1004,12 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card )
             break;
         }
 
-        p_item->ppsz_list =
-            (char **)realloc( p_item->ppsz_list,
+        p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
                               (p_item->i_list + 2) * sizeof(char *) );
-        p_item->ppsz_list_text =
-            (char **)realloc( p_item->ppsz_list_text,
+        assert( p_item->ppsz_list );
+        p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
                               (p_item->i_list + 2) * sizeof(char *) );
+        assert( p_item->ppsz_list_text );
         p_item->ppsz_list[ p_item->i_list ] = psz_device;
         p_item->ppsz_list_text[ p_item->i_list ] = psz_descr;
         p_item->i_list++;
index 8f584afabaf469bdd0393a4bd398b652ef132517..71497d6368855a355a8971e5e29ebf3c62edb9b8 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_charset.h>
+#include <vlc_memory.h>
 
 #include <windows.h>
 #include <mmsystem.h>
@@ -1171,12 +1174,12 @@ static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
 
     int wave_devices = waveOutGetNumDevs();
 
-    p_item->ppsz_list =
-        (char **)realloc( p_item->ppsz_list,
+    p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
                           (wave_devices+2) * sizeof(char *) );
-    p_item->ppsz_list_text =
-        (char **)realloc( p_item->ppsz_list_text,
+    assert( p_item->ppsz_list );
+    p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
                           (wave_devices+2) * sizeof(char *) );
+    assert( p_item->ppsz_list_text );
 
     WAVEOUTCAPS caps;
     char sz_dev_name[MAXPNAMELEN+32];
index 702ae300d3ed4bab1d467d80e6cd8f4379db8b85..da82cbc5f5555195ea5dc7712f6d947239209099 100644 (file)
@@ -36,7 +36,7 @@
 #include "xarray.h"
 
 #ifdef HAVE_STDLIB_H
-#   include <stdlib.h>                                          /* realloc() */
+#   include <stdlib.h>                                           /* malloc() */
 #endif
 
 #undef HISTORY_DEBUG
index 73eeb635fc8137e62dacde4d2e8464e34a9f4c81..f33d47c14f466f448c610567df5cdc0a6ef5b207 100644 (file)
@@ -32,6 +32,8 @@
 #include <string.h>
 #include "xarray.h"
 
+#include <vlc_memory.h>
+
 /* local prototypes */
 XArray * xarray_New (unsigned int);
 
@@ -50,7 +52,7 @@ XArray * xarray_New (unsigned int);
 
 #define XARRAY_GROW_ARRAY(xarray) \
     { \
-        xarray->array = (void *) realloc (xarray->array, xarray->size * 2); \
+        xarray->array = realloc_or_free (xarray->array, xarray->size * 2); \
         if (xarray->array == NULL) return XARRAY_ENOMEM; \
     }
 
index ec4ad75da6bb295d50af821d7dabd4f19cc32e3e..1f40e0e3c6ad63c0ce72e47fd377bf09639be1e5 100644 (file)
@@ -28,6 +28,9 @@
 #endif
 
 #include <stdio.h>
+#include <assert.h>
+
+#include <vlc_memory.h>
 
 #include "xurl.h"
 
@@ -383,6 +386,7 @@ char *XURL_GetHead( const char *psz_path )
 
         i_characters_until_last_slash = pc_last_slash - psz_path;
         psz_path_head = malloc( i_characters_until_last_slash + 1 );
+        assert( psz_path_head );
         strncpy( psz_path_head, psz_path, i_characters_until_last_slash + 1 );
 
         /* terminate the resulting string with '\0' */
@@ -435,7 +439,8 @@ static char *streallocat( char *psz_string, const char *psz_to_append )
     size_t i_new_string_length = strlen( psz_string ) +
         strlen( psz_to_append ) + 1;
 
-    psz_string = (char *) realloc( psz_string, i_new_string_length );
+    psz_string = realloc_or_free( psz_string, i_new_string_length );
+    assert( psz_string );
  
     return strcat( psz_string, psz_to_append );
 }
index bb7d8353731162467eafa650f3f482f05253148d..47ad7db1263cd19bbceed101bf467644e9a0fe8b 100644 (file)
@@ -75,6 +75,7 @@
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_sout.h>
+#include <vlc_memory.h>
 
 #include <vlc_bits.h>
 
@@ -914,6 +915,7 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
         }
 
         p_region->p_pixbuf = malloc( i_height * i_width );
+        assert( p_region->p_pixbuf );
         p_region->i_depth = 0;
         b_fill = true;
     }
@@ -947,9 +949,9 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
 
         /* We create a new object */
         p_region->i_object_defs++;
-        p_region->p_object_defs =
-            realloc( p_region->p_object_defs,
+        p_region->p_object_defs = realloc_or_free( p_region->p_object_defs,
                      sizeof(dvbsub_objectdef_t) * p_region->i_object_defs );
+        assert( p_region->p_object_defs );
 
         /* We parse object properties */
         p_obj = &p_region->p_object_defs[p_region->i_object_defs - 1];
@@ -1165,8 +1167,9 @@ static void decode_object( decoder_t *p_dec, bs_t *s )
                 if( p_region->p_object_defs[i].i_id != i_id ) continue;
 
                 p_region->p_object_defs[i].psz_text =
-                    realloc( p_region->p_object_defs[i].psz_text,
+                    realloc_or_free( p_region->p_object_defs[i].psz_text,
                              i_number_of_codes + 1 );
+                assert( p_region->p_object_defs[i].psz_text );
 
                 /* FIXME 16bits -> char ??? See Preamble */
                 for( j = 0; j < i_number_of_codes; j++ )
@@ -1840,6 +1843,7 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic )
 #ifndef RANDOM_DITHERING
         pi_delta = malloc( ( p_region->p_picture->p[0].i_pitch + 1 )
                             * sizeof(int) * 4  );
+        assert( pi_delta );
         for( i = 0; i < (p_region->p_picture->p[0].i_pitch + 1) * 4 ; i++ )
         {
             pi_delta[ i ] = 0;
@@ -2078,9 +2082,9 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s,
         {
             encoder_region_t region;
             region.i_width = region.i_height = 0;
-            p_sys->p_regions =
-                realloc( p_sys->p_regions, sizeof(encoder_region_t) *
-                         (p_sys->i_regions + 1) );
+            p_sys->p_regions = realloc_or_free( p_sys->p_regions,
+                          sizeof(encoder_region_t) * (p_sys->i_regions + 1) );
+            assert( p_sys->p_regions );
             p_sys->p_regions[p_sys->i_regions++] = region;
         }
 
index 6b21e1a4e04af33860358fb35e7429dbf0c8fe1e..13f0e3020b5ddd90c5d127a8ecea6c000a1ce263 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_aout.h>
+#include <vlc_memory.h>
 
 #ifdef HAVE_FLAC_STREAM_DECODER_H
 #   include <FLAC/stream_decoder.h>
@@ -362,8 +365,9 @@ static void ProcessHeader( decoder_t *p_dec )
     if( p_dec->fmt_out.i_codec == VLC_CODEC_FLAC )
     {
         p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
-        p_dec->fmt_out.p_extra =
-            realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+        p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra,
+                                                  p_dec->fmt_out.i_extra );
+        assert( p_dec->fmt_out.p_extra );
         memcpy( p_dec->fmt_out.p_extra,
                 p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
     }
@@ -1368,7 +1372,8 @@ static block_t *Encode( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
     if( p_sys->i_buffer < p_aout_buf->i_buffer * 2 )
     {
         p_sys->p_buffer =
-            realloc( p_sys->p_buffer, p_aout_buf->i_buffer * 2 );
+            realloc_or_free( p_sys->p_buffer, p_aout_buf->i_buffer * 2 );
+        assert( p_sys->p_buffer );
         p_sys->i_buffer = p_aout_buf->i_buffer * 2;
     }
 
@@ -1437,6 +1442,7 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder,
             /* Backup the STREAMINFO metadata block */
             p_enc->fmt_out.i_extra = STREAMINFO_SIZE + 4;
             p_enc->fmt_out.p_extra = malloc( STREAMINFO_SIZE + 4 );
+            assert( p_enc->fmt_out.p_extra );
             memcpy( p_enc->fmt_out.p_extra, "fLaC", 4 );
             memcpy( ((uint8_t *)p_enc->fmt_out.p_extra) + 4, buffer,
                     STREAMINFO_SIZE );
index 6051554d520fb71c8f3e66bbf60c37db5ef75f9e..d2bf064e9f431c329dec783ef382e761f327aca4 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_input.h>
 #include <vlc_codec.h>
 #include <vlc_osd.h>
+#include <vlc_memory.h>
 
 #include <kate/kate.h>
 #ifdef HAVE_TIGER
@@ -503,8 +506,9 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         /* Backup headers as extra data */
         uint8_t *p_extra;
 
-        p_dec->fmt_in.p_extra =
-            realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + kp.nbytes + 2 );
+        p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra,
+                                      p_dec->fmt_in.i_extra + kp.nbytes + 2 );
+        assert( p_dec->fmt_in.p_extra );
         p_extra = (void*)(((unsigned char*)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra);
         *(p_extra++) = kp.nbytes >> 8;
         *(p_extra++) = kp.nbytes & 0xFF;
@@ -624,8 +628,9 @@ static int ProcessHeaders( decoder_t *p_dec )
     else
     {
         p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
-        p_dec->fmt_out.p_extra =
-            realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+        p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra,
+                                                  p_dec->fmt_out.i_extra );
+        assert( p_dec->fmt_out.p_extra );
         memcpy( p_dec->fmt_out.p_extra,
                 p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
     }
index d902a6e955b32dd0db04418c0753ae0883b989cd..106e5a62603071b2dcb3b1f24e8f5820ad05004b 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_codec.h>
+#include <vlc_memory.h>
 
 #if !defined (__APPLE__) && !defined(WIN32)
 # define LOADER 1
@@ -582,7 +585,8 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
         if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer )
         {
             p_sys->i_buffer_size = p_sys->i_buffer + p_block->i_buffer + 1024;
-            p_sys->p_buffer = realloc( p_sys->p_buffer, p_sys->i_buffer_size );
+            p_sys->p_buffer = realloc_or_free( p_sys->p_buffer, p_sys->i_buffer_size );
+            assert( p_sys->p_buffer );
         }
         memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer,
                 p_block->i_buffer );
index 25da2fc42cc2be0c6822352104885cf66b395818..8c00e9bd98982f749d7f0b1b4cf9992a3e305c65 100644 (file)
@@ -26,6 +26,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
@@ -213,8 +215,8 @@ static int InitVideo(decoder_t *p_dec)
 
     int  i_vide = p_dec->fmt_in.i_extra;
     unsigned int *p_vide = p_dec->fmt_in.p_extra;
-    decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );
-    memset(p_sys,0,sizeof( decoder_sys_t ) );
+    decoder_sys_t *p_sys = calloc( 1, sizeof( decoder_sys_t ) );
+    assert( p_sys );
 
     if( i_vide < 8 )
     {
index b5e0cdf33cfd597c08c7cf3ee5f9d8876790bb37..d7ec977c194bd955cb3936252ad05199c26e4d64 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_input.h>
 #include <vlc_codec.h>
 #include <vlc_aout.h>
+#include <vlc_memory.h>
 
 #include <ogg/ogg.h>
 #include <speex/speex.h>
@@ -306,9 +309,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     {
         uint8_t *p_extra;
 
-        p_dec->fmt_in.p_extra =
-            realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
-                     oggpacket.bytes + 2 );
+        p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra,
+                                p_dec->fmt_in.i_extra + oggpacket.bytes + 2 );
+        assert( p_dec->fmt_in.p_extra );
         p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra;
         *(p_extra++) = oggpacket.bytes >> 8;
         *(p_extra++) = oggpacket.bytes & 0xFF;
@@ -392,8 +395,9 @@ static int ProcessHeaders( decoder_t *p_dec )
     if( p_sys->b_packetizer )
     {
         p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
-        p_dec->fmt_out.p_extra =
-            realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+        p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra,
+                                                  p_dec->fmt_out.i_extra );
+        assert( p_dec->fmt_out.p_extra );
         memcpy( p_dec->fmt_out.p_extra,
                 p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
     }
@@ -530,6 +534,7 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
 
            i_pcm_output_size = p_sys->p_header->frame_size;
            p_frame_holder = (short*)malloc( sizeof(short)*i_pcm_output_size );
+            assert( p_frame_holder );
 
             speex_bits_read_from( &p_sys->bits, (char*)p_oggpacket->packet,
                p_oggpacket->bytes);
@@ -1001,6 +1006,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     p_sys->i_frame_size = p_sys->i_frame_length *
         sizeof(int16_t) * p_enc->fmt_in.audio.i_channels;
     p_sys->p_buffer = malloc( p_sys->i_frame_size );
+    assert( p_sys->p_buffer );
 
     /* Create and store headers */
     pp_header[0] = speex_header_to_packet( &p_sys->header, &pi_header[0] );
@@ -1009,6 +1015,7 @@ static int OpenEncoder( vlc_object_t *p_this )
 
     p_enc->fmt_out.i_extra = 3 * 2 + pi_header[0] + pi_header[1];
     p_extra = p_enc->fmt_out.p_extra = malloc( p_enc->fmt_out.i_extra );
+    assert( p_extra );
     for( i = 0; i < 2; i++ )
     {
         *(p_extra++) = pi_header[i] >> 8;
index e1d729cab4f03b76bc726337551cc6368f61e69f..d1b7572e44f53d7e8702fb379d25cef1b015e838 100644 (file)
@@ -31,6 +31,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include "subsdec.h"
 #include <vlc_plugin.h>
 
@@ -458,6 +460,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
             char *psz_convert_buffer_out = psz_new_subtitle;
             const char *psz_convert_buffer_in = psz_subtitle;
 
+            assert( psz_new_subtitle );
+
             size_t ret = vlc_iconv( p_sys->iconv_handle,
                                     &psz_convert_buffer_in, &inbytes_left,
                                     &psz_convert_buffer_out, &outbytes_left );
@@ -476,6 +480,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
 
             psz_subtitle = realloc( psz_new_subtitle,
                                     psz_convert_buffer_out - psz_new_subtitle );
+            if( !psz_subtitle )
+                psz_subtitle = psz_new_subtitle;
         }
     }
 
@@ -617,7 +623,8 @@ static char *StripTags( char *psz_subtitle )
         psz_subtitle++;
     }
     *psz_text = '\0';
-    psz_text_start = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+    char *psz = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+    if( psz ) psz_text_start = psz;
 
     return psz_text_start;
 }
index 54b303194daa182f53ea3248fd6b6715fcc2d8ba..46db35323a11de2ae1b6eae99e83c94c35e47262 100644 (file)
@@ -1085,7 +1085,9 @@ static char *StripTags( char *psz_subtitle )
         psz_subtitle++;
     }
     *psz_text = '\0';
-    psz_text_start = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+
+    char *psz = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+    if( psz ) psz_text_start = psz;
 
     return psz_text_start;
 }
index df5b4844df285e027bb814a2a7196fc556cd254f..8f5e328f02499f90cf508194a403604aaf1aa2df 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_sout.h>
 #include <vlc_input.h>
+#include <vlc_memory.h>
 #include <ogg/ogg.h>
 
 #include <theora/theora.h>
@@ -215,9 +218,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         /* Backup headers as extra data */
         uint8_t *p_extra;
 
-        p_dec->fmt_in.p_extra =
-            realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
-                     oggpacket.bytes + 2 );
+        p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra,
+                                p_dec->fmt_in.i_extra + oggpacket.bytes + 2 );
+        assert( p_dec->fmt_in.p_extra );
         p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra;
         *(p_extra++) = oggpacket.bytes >> 8;
         *(p_extra++) = oggpacket.bytes & 0xFF;
@@ -404,8 +407,9 @@ static int ProcessHeaders( decoder_t *p_dec )
     else
     {
         p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
-        p_dec->fmt_out.p_extra =
-            realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+        p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra,
+                                                  p_dec->fmt_out.i_extra );
+        assert( p_dec->fmt_out.p_extra );
         memcpy( p_dec->fmt_out.p_extra,
                 p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
     }
@@ -706,9 +710,9 @@ static int OpenEncoder( vlc_object_t *p_this )
         else if( i == 1 ) theora_encode_comment( &p_sys->tc, &header );
         else if( i == 2 ) theora_encode_tables( &p_sys->td, &header );
 
-        p_enc->fmt_out.p_extra =
-            realloc( p_enc->fmt_out.p_extra,
-                     p_enc->fmt_out.i_extra + header.bytes );
+        p_enc->fmt_out.p_extra = realloc_or_free( p_enc->fmt_out.p_extra,
+                                      p_enc->fmt_out.i_extra + header.bytes );
+        assert( p_enc->fmt_out.p_extra );
         p_extra = p_enc->fmt_out.p_extra;
         p_extra += p_enc->fmt_out.i_extra + (i-3)*2;
         p_enc->fmt_out.i_extra += header.bytes;
index 03a3053cb3a67d44337f03e7eef9c89bbd75cdda..d4598129c7f7a16d4ef9111bf75e2f33bec0d2f7 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_aout.h>
 #include <vlc_input.h>
 #include <vlc_sout.h>
+#include <vlc_memory.h>
 
 #include <ogg/ogg.h>
 
@@ -318,9 +321,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         /* Backup headers as extra data */
         uint8_t *p_extra;
 
-        p_dec->fmt_in.p_extra =
-            realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
-                     oggpacket.bytes + 2 );
+        p_dec->fmt_in.p_extra = realloc_or_free( p_dec->fmt_in.p_extra,
+                                p_dec->fmt_in.i_extra + oggpacket.bytes + 2 );
+        assert( p_dec->fmt_in.p_extra );
         p_extra = (uint8_t *)p_dec->fmt_in.p_extra + p_dec->fmt_in.i_extra;
         *(p_extra++) = oggpacket.bytes >> 8;
         *(p_extra++) = oggpacket.bytes & 0xFF;
@@ -454,8 +457,9 @@ static int ProcessHeaders( decoder_t *p_dec )
     else
     {
         p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
-        p_dec->fmt_out.p_extra =
-            realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+        p_dec->fmt_out.p_extra = realloc_or_free( p_dec->fmt_out.p_extra,
+                                                  p_dec->fmt_out.i_extra );
+        assert( p_dec->fmt_out.p_extra );
         memcpy( p_dec->fmt_out.p_extra,
                 p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
     }
@@ -879,6 +883,7 @@ static int OpenEncoder( vlc_object_t *p_this )
     p_enc->fmt_out.i_extra = 3 * 2 + header[0].bytes +
        header[1].bytes + header[2].bytes;
     p_extra = p_enc->fmt_out.p_extra = malloc( p_enc->fmt_out.i_extra );
+    assert( p_extra );
     for( i = 0; i < 3; i++ )
     {
         *(p_extra++) = header[i].bytes >> 8;
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 );
index 09d6ebd4d54c72a32f2a7537b3201d4e774b9c3a..9e9deb9b1c8f6075ab5bfe2c574cde921bb6234f 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <assert.h>
 
+#include <vlc_memory.h>
+
 /* Utility function for scandir */
 static int Filter( const char *foo )
 {
@@ -55,6 +57,7 @@ mvar_t *mvar_New( const char *name, const char *value )
 
     v->i_field = 0;
     v->field = malloc( sizeof( mvar_t * ) );
+    assert( v->field );
     v->field[0] = NULL;
 
     return v;
@@ -77,7 +80,9 @@ void mvar_Delete( mvar_t *v )
 
 void mvar_AppendVar( mvar_t *v, mvar_t *f )
 {
-    v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+    v->field = realloc_or_free( v->field,
+                                sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+    assert( v->field );
     v->field[v->i_field] = f;
     v->i_field++;
 }
@@ -98,7 +103,9 @@ mvar_t *mvar_Duplicate( const mvar_t *v )
 
 void mvar_PushVar( mvar_t *v, mvar_t *f )
 {
-    v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+    v->field = realloc_or_free( v->field,
+                                sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+    assert( v->field );
     if( v->i_field > 0 )
     {
         memmove( &v->field[1], &v->field[0], sizeof( mvar_t * ) * v->i_field );
index 1226002e20904a1697114694f1c06c2a9d1bed4a..70288be4e43a0ffe15694d2a59f1ab641a9864b9 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include "http.h"
 #include <vlc_strings.h>
+#include <vlc_memory.h>
 
 /****************************************************************************
  * File and directory functions
@@ -91,10 +94,13 @@ int FileLoad( FILE *f, char **pp_data, int *pi_data )
     /* just load the file */
     *pi_data = 0;
     *pp_data = malloc( 1025 );  /* +1 for \0 */
+    assert( *pp_data );
+
     while( ( i_read = fread( &(*pp_data)[*pi_data], 1, 1024, f ) ) == 1024 )
     {
         *pi_data += 1024;
-        *pp_data = realloc( *pp_data, *pi_data  + 1025 );
+        *pp_data = realloc_or_free( *pp_data, *pi_data  + 1025 );
+        assert( *pp_data );
     }
     if( i_read > 0 )
     {
@@ -235,6 +241,7 @@ int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
                 f = malloc( sizeof( httpd_file_sys_t ) );
                 f->b_handler = false;
             }
+            assert( f );
 
             f->p_intf  = p_intf;
             f->p_file = NULL;
@@ -921,6 +928,7 @@ char *RealPath( const char *psz_src )
     int i_len = strlen(psz_src);
 
     psz_dir = malloc( i_len + 2 );
+    assert( psz_dir );
     strcpy( psz_dir, psz_src );
 
     /* Add a trailing sep to ease the .. step */
index 2baa832c4b27aea7d431ef73f1a5e74db010de4f..cf69965ac698c5bc97f7530a82355344a11f98d9 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_memory.h>
 
 #include <errno.h>                                                 /* ENOMEM */
 #include <ctype.h>
@@ -2106,7 +2109,9 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl )
         else if( *psz_item )
         {
             i_options++;
-            ppsz_options = realloc( ppsz_options, i_options * sizeof(char *) );
+            ppsz_options = realloc_or_free( ppsz_options,
+                                            i_options * sizeof(char *) );
+            assert( ppsz_options );
             ppsz_options[i_options - 1] = &psz_item[1];
         }
 
index ad7612390a3fa22408f62121e5e5f1a9352a408c..866200dca6a26dffb939c1e9d174fb193bac364c 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_interface.h>
 #include <vlc_input.h>
+#include <vlc_memory.h>
 
 #include <stdbool.h>
 #include <sys/stat.h>
@@ -573,6 +576,7 @@ static char *MessageToString( vlm_message_t *message, int i_level )
 
     i_message += strlen( message->psz_name ) + i_level * sizeof( "    " ) + 1;
     psz_message = malloc( i_message );
+    assert( psz_message );
     *psz_message = 0;
     for( i = 0; i < i_level; i++ ) strcat( psz_message, "    " );
     strcat( psz_message, message->psz_name );
@@ -581,7 +585,8 @@ static char *MessageToString( vlm_message_t *message, int i_level )
     {
         i_message += sizeof( " : " ) + strlen( message->psz_value ) +
             sizeof( STRING_CR );
-        psz_message = realloc( psz_message, i_message );
+        psz_message = realloc_or_free( psz_message, i_message );
+        assert( psz_message );
         strcat( psz_message, " : " );
         strcat( psz_message, message->psz_value );
         strcat( psz_message, STRING_CR );
@@ -589,7 +594,8 @@ static char *MessageToString( vlm_message_t *message, int i_level )
     else
     {
         i_message += sizeof( STRING_CR );
-        psz_message = realloc( psz_message, i_message );
+        psz_message = realloc_or_free( psz_message, i_message );
+        assert( psz_message );
         strcat( psz_message, STRING_CR );
     }
 
@@ -599,7 +605,8 @@ static char *MessageToString( vlm_message_t *message, int i_level )
             MessageToString( message->child[i], i_level + 1 );
 
         i_message += strlen( child_message );
-        psz_message = realloc( psz_message, i_message );
+        psz_message = realloc_or_free( psz_message, i_message );
+        assert( psz_message );
         strcat( psz_message, child_message );
         free( child_message );
     }
index 276d77cd3ea97d4cd87f396f2f4be6c814f6c652..0739b58a76162c090d417988ca8794c373704441 100644 (file)
 #include <vlc_common.h>
 #include <vlc_input.h>
 #include <vlc_demux.h>
+#include <vlc_memory.h>
 
 #include <limits.h>
 #include <string.h>
+#include <assert.h>
 
 #include "asademux.h"
 
@@ -45,7 +47,7 @@
 #define MAXGROUP       24      /**< maximum number of regex match groups */
 
 #define xmalloc malloc
-#define xrealloc realloc
+#define xrealloc realloc_or_free
 #define xfree free
 #define xstrdup strdup
 
@@ -247,6 +249,7 @@ static int asai_select (struct asa_import_state *state,
        if (state->selstr)
                xfree(state->selstr);
        state->selstr = xstrdup(state->matches[insn->v.select]);
+       assert(state->selstr);
        state->sellen = strlen(state->selstr);
        return 0;
 }
@@ -262,6 +265,7 @@ static ptrdiff_t asai_process_replace(struct asa_import_state *state,
 
        newstr_size = v[0] * 2;
        newstr = (char *)xmalloc(newstr_size);
+       assert(newstr);
        memcpy(newstr, state->selstr, v[0]);
        newpos = v[0];
 
@@ -286,6 +290,7 @@ static ptrdiff_t asai_process_replace(struct asa_import_state *state,
                if (need > avail) {
                        newstr_size += need - avail + 256;
                        newstr = (char *)xrealloc(newstr, newstr_size);
+                       assert(newstr);
                }
                memcpy(newstr + newpos, src, need);
                newpos += need;
@@ -293,6 +298,7 @@ static ptrdiff_t asai_process_replace(struct asa_import_state *state,
        firstold = newpos;
        newstr_size = newpos + state->sellen - v[1];
        newstr = (char *)xrealloc(newstr, newstr_size + 1);
+       assert(newstr);
        memcpy(newstr + newpos, state->selstr + v[1],
                state->sellen - v[1] + 1);
        state->selstr = newstr;
@@ -352,6 +358,7 @@ static void asai_set_matches(struct asa_import_state *state,
        if (state->selstr)
                xfree(state->selstr);
        state->selstr = xstrdup(state->matches[0]);
+       assert(state->selstr);
        state->sellen = strlen(state->selstr);
 }
 
@@ -383,6 +390,7 @@ static int asai_append (struct asa_import_state *state,
 {
        state->out = (char *)xrealloc(state->out,
                state->outlen + state->sellen + 1);
+       assert(state->out);
        memcpy(state->out + state->outlen, state->selstr, state->sellen);
        state->outlen += state->sellen;
        state->out[state->outlen] = '\0';
index 85db8835076fdc06644b43d3c16c56a80111e7af..9e530fcd3f8e617473ca6d2794efe15ec6724ec3 100644 (file)
@@ -37,6 +37,7 @@
 #include <vlc_meta.h>
 #include <vlc_codecs.h>
 #include <vlc_charset.h>
+#include <vlc_memory.h>
 
 #include "libavi.h"
 
@@ -2107,8 +2108,8 @@ static void AVI_IndexAddEntry( demux_sys_t *p_sys,
     if( tk->i_idxnb >= tk->i_idxmax )
     {
         tk->i_idxmax += 16384;
-        tk->p_index = realloc( tk->p_index,
-                               tk->i_idxmax * sizeof( avi_entry_t ) );
+        tk->p_index = realloc_or_free( tk->p_index,
+                                       tk->i_idxmax * sizeof( avi_entry_t ) );
         if( tk->p_index == NULL )
         {
             return;
index e24f04b9d059b8134d3ffea83ecc0a39f1c08bf1..d0ec1ce931b310fe2d54e84345b42d4274601fe3 100644 (file)
@@ -148,10 +148,12 @@ static int Open( vlc_object_t *p_this )
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = (demux_sys_t *)malloc( sizeof( demux_sys_t ) );
+    assert(p_sys);
 
     msg_Dbg( p_demux, "loading complete file (could be long)" );
     p_sys->i_data = stream_Size( p_demux->s );
     p_sys->p_data = (uint8_t *)malloc( p_sys->i_data );
+    assert(p_sys->p_data);
     p_sys->i_data = stream_Read( p_demux->s, p_sys->p_data, p_sys->i_data );
     if( p_sys->i_data <= 0 )
     {
@@ -455,6 +457,7 @@ switch( i_query )
 
                 *pi_int = p_sys->i_tracks;
                 *ppp_title = (input_title_t**)malloc( sizeof( input_title_t**) * p_sys->i_tracks );
+                assert( *ppp_sitle );
 
                 for( int i = 0; i < p_sys->i_tracks; i++ )
                 {
@@ -499,6 +502,7 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff
 
     out_size = i_size * 2;
     out_buffer = (uint8_t*)malloc(out_size);
+    assert(out_buffer);
 
     z_str.next_in   = (unsigned char*)p_buffer;
     z_str.avail_in  = i_size;
@@ -520,7 +524,8 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff
         case Z_BUF_ERROR:
             offset = z_str.next_out - out_buffer;
             out_size *= 2;
-            out_buffer = (uint8_t *)realloc(out_buffer, out_size);
+            out_buffer = (uint8_t *)realloc_or_free(out_buffer, out_size);
+            assert(out_buffer);
             z_str.next_out  = out_buffer + offset;
             z_str.avail_out = out_size - offset;
             break;
@@ -535,7 +540,8 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff
 
     inflateEnd(&z_str);
  
-    out_buffer = (uint8_t *)realloc(out_buffer, *pi_osize);
+    out_buffer = (uint8_t *)realloc_or_free(out_buffer, *pi_osize);
+    assert(out_buffer);
     (*pp_obuffer) = out_buffer;
 }
 #endif
index 118360699380b8e3f8ff5a42a29ae0da676e5ce3..cdf6adbe6bc6ba0bae6daf6507c59f8fb2ef809f 100644 (file)
@@ -45,6 +45,7 @@
 #include <vlc_dialog.h>
 #include <vlc_url.h>
 #include <vlc_strings.h>
+#include <vlc_memory.h>
 
 #include <iostream>
 #include <limits.h>
@@ -367,7 +368,8 @@ static int  Open ( vlc_object_t *p_this )
             }
 
             i_sdp_max += 1000;
-            p_sdp = (uint8_t*)realloc( p_sdp, i_sdp_max );
+            p_sdp = (uint8_t*)realloc_or_free( p_sdp, i_sdp_max );
+            assert( p_sdp );
         }
         p_sys->p_sdp = (char*)p_sdp;
     }
@@ -867,6 +869,7 @@ static int SessionsSetup( demux_t *p_demux )
                     {
                         tk->fmt.i_extra = i_extra;
                         tk->fmt.p_extra = malloc( i_extra );
+                        assert( tk->fmt.p_extra );
                         memcpy( tk->fmt.p_extra, p_extra, i_extra );
                         delete[] p_extra;
                     }
@@ -887,6 +890,7 @@ static int SessionsSetup( demux_t *p_demux )
                     {
                         tk->fmt.i_extra = i_extra;
                         tk->fmt.p_extra = malloc( i_extra );
+                        assert( tk->fmt.p_extra );
                         memcpy( tk->fmt.p_extra, p_extra, i_extra );
                         delete[] p_extra;
                     }
@@ -945,6 +949,7 @@ static int SessionsSetup( demux_t *p_demux )
                     {
                         tk->fmt.i_extra = i_extra;
                         tk->fmt.p_extra = malloc( i_extra );
+                        assert( tk->fmt.p_extra );
                         memcpy( tk->fmt.p_extra, p_extra, i_extra );
 
                         delete[] p_extra;
@@ -966,6 +971,7 @@ static int SessionsSetup( demux_t *p_demux )
                     {
                         tk->fmt.i_extra = i_extra;
                         tk->fmt.p_extra = malloc( i_extra );
+                        assert( tk->fmt.p_extra );
                         memcpy( tk->fmt.p_extra, p_extra, i_extra );
                         delete[] p_extra;
                     }
@@ -1028,7 +1034,9 @@ static int SessionsSetup( demux_t *p_demux )
             if( tk->p_es || tk->b_quicktime || tk->b_muxed || tk->b_asf )
             {
                 /* Append */
-                p_sys->track = (live_track_t**)realloc( p_sys->track, sizeof( live_track_t ) * ( p_sys->i_track + 1 ) );
+                p_sys->track = (live_track_t**)realloc_or_free( p_sys->track,
+                            sizeof( live_track_t ) * ( p_sys->i_track + 1 ) );
+                assert( p_sys->track );
                 p_sys->track[p_sys->i_track++] = tk;
             }
             else
@@ -1618,6 +1626,7 @@ static void StreamRead( void *p_private, unsigned int i_size,
                     {
                         tk->fmt.i_extra = atomLength-8;
                         tk->fmt.p_extra = malloc( tk->fmt.i_extra );
+                        assert( tk->fmt.p_extra );
                         memcpy(tk->fmt.p_extra, pos+8, atomLength-8);
                         break;
                     }
@@ -1628,6 +1637,7 @@ static void StreamRead( void *p_private, unsigned int i_size,
             {
                 tk->fmt.i_extra        = qtState.sdAtomSize - 16;
                 tk->fmt.p_extra        = malloc( tk->fmt.i_extra );
+                assert( tk->fmt.p_extra );
                 memcpy( tk->fmt.p_extra, &sdAtom[12], tk->fmt.i_extra );
             }
         }
index eb359baf78b4f67a1ce476edfaf09785c598396a..2772f7060c84a52c2b6001760db17577540eee5d 100644 (file)
@@ -26,6 +26,9 @@
 
 #include "chapter_command.hpp"
 
+#include <assert.h>
+#include <vlc_memory.h>
+
 chapter_item_c::~chapter_item_c()
 {
     std::vector<chapter_codec_cmds_c*>::iterator index = codecs.begin();
@@ -62,7 +65,9 @@ int chapter_item_c::PublishChapters( input_title_t & title, int & i_user_chapter
 
         // A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value.
         title.i_seekpoint++;
-        title.seekpoint = (seekpoint_t**)realloc( title.seekpoint, title.i_seekpoint * sizeof( seekpoint_t* ) );
+        title.seekpoint = realloc_or_free( title.seekpoint,
+                                 title.i_seekpoint * sizeof( seekpoint_t* ) );
+        assert( title.seekpoint );
         title.seekpoint[title.i_seekpoint-1] = sk;
 
         if ( b_user_display )
index 59dd144e60b962556c6ca1a9ac8fc6c0aed7f485..67124c7f114a2148b5c91da03e56ef7b05fe537c 100644 (file)
@@ -28,6 +28,9 @@
 
 #include "demux.hpp"
 
+#include <assert.h>
+#include <vlc_memory.h>
+
 extern "C" {
 #include "../vobsub.h"
 }
@@ -179,7 +182,9 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
             if( i_index >= i_index_max )
             {
                 i_index_max += 1024;
-                p_indexes = (mkv_index_t*)realloc( p_indexes, sizeof( mkv_index_t ) * i_index_max );
+                p_indexes = realloc_or_free( p_indexes,
+                                        sizeof( mkv_index_t ) * i_index_max );
+                assert( p_indexes );
             }
 #undef idx
         }
@@ -372,7 +377,9 @@ void matroska_segment_c::IndexAppendCluster( KaxCluster *cluster )
     if( i_index >= i_index_max )
     {
         i_index_max += 1024;
-        p_indexes = (mkv_index_t*)realloc( p_indexes, sizeof( mkv_index_t ) * i_index_max );
+        p_indexes = realloc_or_free( p_indexes,
+                                        sizeof( mkv_index_t ) * i_index_max );
+        assert( p_indexes );
     }
 #undef idx
 }
@@ -665,6 +672,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
                 if( tracks[i_track]->fmt.i_extra > 0 )
                 {
                     tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra );
+                    assert( tracks[i_track]->fmt.p_extra );
                     memcpy( tracks[i_track]->fmt.p_extra, &p_bih[1], tracks[i_track]->fmt.i_extra );
                 }
             }
@@ -716,6 +724,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
                     if( i_size1 > 0 && i_size2 > 0 && i_size3 > 0  ) {
                         tracks[i_track]->fmt.p_extra =
                             malloc( tracks[i_track]->fmt.i_extra );
+                        assert( tracks[i_track]->fmt.p_extra );
                         uint8_t *p_out = (uint8_t*)tracks[i_track]->fmt.p_extra;
                         *p_out++ = (i_size1>>8) & 0xFF;
                         *p_out++ = i_size1 & 0xFF;
@@ -786,12 +795,14 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
                     tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4V;
                 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
                 tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
+                assert( tracks[i_track]->fmt.p_extra );
                 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
             }
         }
         else if( !strcmp( tracks[i_track]->psz_codec, "V_QUICKTIME" ) )
         {
             MP4_Box_t *p_box = (MP4_Box_t*)malloc( sizeof( MP4_Box_t ) );
+            assert( p_box );
             stream_t *p_mp4_stream = stream_MemoryNew( VLC_OBJECT(&sys.demuxer),
                                                        tracks[i_track]->p_extra_data,
                                                        tracks[i_track]->i_extra_data,
@@ -804,6 +815,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
                 tracks[i_track]->fmt.video.i_height = p_box->data.p_sample_vide->i_height;
                 tracks[i_track]->fmt.i_extra = p_box->data.p_sample_vide->i_qt_image_description;
                 tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra );
+                assert( tracks[i_track]->fmt.p_extra );
                 memcpy( tracks[i_track]->fmt.p_extra, p_box->data.p_sample_vide->p_qt_image_description, tracks[i_track]->fmt.i_extra );
                 MP4_FreeBox_sample_vide( p_box );
             }
@@ -836,6 +848,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
                 if( tracks[i_track]->fmt.i_extra > 0 )
                 {
                     tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra );
+                    assert( tracks[i_track]->fmt.p_extra );
                     memcpy( tracks[i_track]->fmt.p_extra, &p_wf[1], tracks[i_track]->fmt.i_extra );
                 }
             }
@@ -873,6 +886,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             tracks[i_track]->fmt.i_codec = VLC_CODEC_FLAC;
             tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
             tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
+            assert( tracks[i_track]->fmt.p_extra );
             memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
         }
         else if( !strcmp( tracks[i_track]->psz_codec, "A_VORBIS" ) )
@@ -902,6 +916,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
 
             tracks[i_track]->fmt.i_extra = 3 * 2 + i_size[0] + i_size[1] + i_size[2];
             tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra );
+            assert( tracks[i_track]->fmt.p_extra );
             p_extra = (uint8_t *)tracks[i_track]->fmt.p_extra; i_extra = 0;
             for( i = 0; i < 3; i++ )
             {
@@ -959,6 +974,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
 
             tracks[i_track]->fmt.i_extra = sbr ? 5 : 2;
             tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra );
+            assert( tracks[i_track]->fmt.p_extra );
             ((uint8_t*)tracks[i_track]->fmt.p_extra)[0] = ((i_profile + 1) << 3) | ((i_srate&0xe) >> 1);
             ((uint8_t*)tracks[i_track]->fmt.p_extra)[1] = ((i_srate & 0x1) << 7) | (tracks[i_track]->fmt.audio.i_channels << 3);
             if (sbr != 0)
@@ -978,6 +994,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4A;
             tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
             tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
+            assert( tracks[i_track]->fmt.p_extra );
             memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
         }
         else if( !strcmp( tracks[i_track]->psz_codec, "A_WAVPACK4" ) )
@@ -985,6 +1002,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             tracks[i_track]->fmt.i_codec = VLC_CODEC_WAVPACK;
             tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
             tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
+            assert( tracks[i_track]->fmt.p_extra );
             memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
         }
         else if( !strcmp( tracks[i_track]->psz_codec, "A_TTA1" ) )
@@ -994,16 +1012,14 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             if( p_fmt->i_extra > 0 )
             {
                 p_fmt->p_extra = malloc( p_tk->i_extra_data );
-                if( !p_fmt->p_extra )
-                    abort();
+                assert( p_fmt->p_extra );
                 memcpy( p_fmt->p_extra, p_tk->p_extra_data, p_tk->i_extra_data );
             }
             else
             {
                 p_fmt->i_extra = 30;
                 p_fmt->p_extra = malloc( p_fmt->i_extra );
-                if( !p_fmt->p_extra )
-                    abort();
+                assert( p_fmt->p_extra );
                 uint8_t *p_extra = (uint8_t*)p_fmt->p_extra;
                 memcpy( &p_extra[ 0], "TTA1", 4 );
                 SetWLE( &p_extra[ 4], 1 );
@@ -1063,6 +1079,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
 
             tracks[i_track]->fmt.i_extra = 1 + num_headers * 2 + size_so_far + pi_size[num_headers-1];
             tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->fmt.i_extra );
+            assert( tracks[i_track]->fmt.p_extra );
 
             p_extra = (uint8_t *)tracks[i_track]->fmt.p_extra;
             i_extra = 0;
@@ -1097,6 +1114,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             {
                 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
                 tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
+                assert( tracks[i_track]->fmt.p_extra );
                 memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
             }
         }
@@ -1111,6 +1129,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
             {
                 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
                 tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
+                assert( tracks[i_track]->fmt.p_extra );
                 memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
             }
         }
index d32c6712a8f5dedab4c96ae6fb1d4fdc70de8a2c..31abc9765dabec184f94fa52bee09f3d3371c01e 100644 (file)
@@ -32,6 +32,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
+#include <vlc_memory.h>
 
 /* TODO:
  *  - test
@@ -923,8 +924,9 @@ static void demux_IndexAppend( demux_index_t *p_idx,
         else
         {
             p_idx->i_idx_max += 1000;
-            p_idx->idx = realloc( p_idx->idx,
-                                  p_idx->i_idx_max*sizeof(demux_index_entry_t));
+            p_idx->idx = realloc_or_free( p_idx->idx,
+                                p_idx->i_idx_max*sizeof(demux_index_entry_t));
+            assert( p_idx->idx );
         }
     }
 
index c41c962756b8ef227e1e6b95c88dba79536595c9..71f5d601c5096721e182bf65bf740c8a4545e585 100644 (file)
@@ -671,7 +671,9 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         p_stream->p_headers =
             realloc( p_sav = p_stream->p_headers, p_stream->i_headers +
                      p_oggpacket->bytes + (b_store_size ? 2 : 0) + (b_store_num_headers ? 1 : 0) );
-        if( p_stream->p_headers )
+        if( !p_stream->p_headers )
+            p_stream->p_headers = p_sav;
+        else
         {
             uint8_t *p_extra = p_stream->p_headers + p_stream->i_headers;
 
@@ -714,10 +716,6 @@ static void Ogg_DecodePacket( demux_t *p_demux,
                 p_ogg->i_bos--;
             }
         }
-        else
-        {
-                p_stream->p_headers = p_sav;
-        }
 
         b_selected = false; /* Discard the header packet */
     }
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);
index d456dfb0bb78bf5ed0d69563a7329734f6b67a08..a4e176096472814183630353a020e8e26ca9432f 100644 (file)
@@ -21,8 +21,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <vlc_demux.h>
 #include <assert.h>
+#include <vlc_demux.h>
+#include <vlc_memory.h>
 
 /* 256-0xC0 for normal stream, 256 for 0xbd stream, 256 for 0xfd stream, 8 for 0xa0 AOB stream */
 #define PS_TK_COUNT (256+256+256+8 - 0xc0)
@@ -642,7 +643,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
             }
         }
 
-        tmp_es = realloc( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) );
+        tmp_es = realloc_or_free( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) );
         if( tmp_es )
         {
             p_psm->es = tmp_es;
index 4faaa9cdcc473b7f4fdfc113fc0ff102b5cca1de..69e6978ba1d047c22c722777212e9251a3d199ea 100644 (file)
@@ -34,6 +34,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_input.h>
+#include <vlc_memory.h>
 
 #include <errno.h>
 #ifdef HAVE_SYS_TYPES_H
@@ -481,10 +482,9 @@ static int Open ( vlc_object_t *p_this )
         if( p_sys->i_subtitles >= i_max )
         {
             i_max += 500;
-            if( !( p_sys->subtitle = realloc( p_sys->subtitle,
+            if( !( p_sys->subtitle = realloc_or_free( p_sys->subtitle,
                                               sizeof(subtitle_t) * i_max ) ) )
             {
-                free( p_sys->subtitle );
                 TextUnload( &p_sys->txt );
                 free( p_sys );
                 return VLC_ENOMEM;
@@ -747,6 +747,8 @@ static int TextLoad( text_t *txt, stream_t *s )
     txt->i_line_count   = 0;
     txt->i_line         = 0;
     txt->line           = calloc( i_line_max, sizeof( char * ) );
+    if( !txt->line )
+        return VLC_ENOMEM;
 
     /* load the complete file */
     for( ;; )
@@ -760,8 +762,11 @@ static int TextLoad( text_t *txt, stream_t *s )
         if( txt->i_line_count >= i_line_max )
         {
             i_line_max += 100;
-            txt->line = realloc( txt->line, i_line_max * sizeof( char * ) );
+            txt->line = realloc_or_free( txt->line, i_line_max * sizeof( char * ) );
+            if( !txt->line )
+                return VLC_ENOMEM;
         }
+        free( psz );
     }
 
     if( txt->i_line_count <= 0 )
@@ -928,7 +933,7 @@ static int ParseSubRipSubViewer( demux_t *p_demux, subtitle_t *p_subtitle,
         }
 
         i_old = strlen( psz_text );
-        psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+        psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
         {
             return VLC_ENOMEM;
@@ -1061,9 +1066,9 @@ static int  ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle,
         if( !p_sys->psz_header )
             return VLC_ENOMEM;
 
-        p_sys->psz_header =
-            realloc( p_sys->psz_header,
-                     strlen( p_sys->psz_header ) + strlen( s ) + 2 );
+        p_sys->psz_header = realloc_or_free( p_sys->psz_header,
+                              strlen( p_sys->psz_header ) + strlen( s ) + 2 );
+        assert( p_sys->psz_header );
         strcat( p_sys->psz_header,  s );
         strcat( p_sys->psz_header, "\n" );
     }
@@ -1295,7 +1300,7 @@ static int ParseDVDSubtitle( demux_t *p_demux, subtitle_t *p_subtitle,
         }
 
         i_old = strlen( psz_text );
-        psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+        psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
             return VLC_ENOMEM;
         strcat( psz_text, s );
@@ -1402,7 +1407,7 @@ static int ParseAQT( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
         else
         {
             i_old = strlen( psz_text ) + 1;
-            psz_text = realloc( psz_text, i_old + strlen( s ) + 1 );
+            psz_text = realloc_or_free( psz_text, i_old + strlen( s ) + 1 );
             if( !psz_text )
                  return VLC_ENOMEM;
             strcat( psz_text, s );
@@ -1548,7 +1553,7 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
 
         int i_old = strlen( psz_text );
 
-        psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+        psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
              return VLC_ENOMEM;
 
@@ -1694,7 +1699,7 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
 
         int i_old = strlen( psz_text );
 
-        psz_text = realloc( psz_text, i_old + i_len + 1 );
+        psz_text = realloc_or_free( psz_text, i_old + i_len + 1 );
         if( !psz_text )
              return VLC_ENOMEM;
 
@@ -1714,6 +1719,7 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
         /* Directives are NOT parsed yet */
         /* This has probably a better place in a decoder ? */
         /* directive = malloc( strlen( psz_text ) + 1 );
+           assert( directive );
            if( sscanf( psz_text, "%s %[^\n\r]", directive, psz_text2 ) == 2 )*/
     }
 
@@ -1942,7 +1948,7 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
 
         int i_old = strlen( psz_text );
 
-        psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+        psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
             return VLC_ENOMEM;
 
index 4882206a3cbd53a7b2bd34a0416d339b745cfaf4..381a4d20a2bfaa9491bc2bedd15872a2215f3339 100644 (file)
@@ -33,6 +33,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_input.h>
+#include <vlc_memory.h>
 
 
 #include <errno.h>
@@ -280,8 +281,8 @@ static int ProcessLine( demux_t *p_demux, void *p_arg,
     if( p_sys->i_subtitles >= p_sys->i_subs_alloc )
     {
         p_sys->i_subs_alloc += 500;
-        if( !( p_sys->subtitle = realloc( p_sys->subtitle, sizeof(subtitle_t)
-                                          * p_sys->i_subs_alloc ) ) )
+        if( !( p_sys->subtitle = realloc_or_free( p_sys->subtitle,
+                                sizeof(subtitle_t) * p_sys->i_subs_alloc ) ) )
         {
             return VLC_ENOMEM;
         }
index 1a5125958374fd9fa64800c38377f9586267b4d2..7745445179a973b776abd2e9b5b942617e9b6b2e 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_memory.h>
 
 #include <ctype.h>
 #include <assert.h>
@@ -515,6 +516,10 @@ static int Open( vlc_object_t *p_this )
         char *psz_event_text = malloc(130);
         char *psz_ext_text = malloc(1025);
 
+        assert( psz_name );
+        assert( psz_event_text );
+        assert( psz_ext_text );
+
         // 2 bytes version Uimsbf (4,5)
         // 2 bytes reserved (6,7)
         // 2 bytes duration in minutes Uimsbf (8,9(
@@ -619,6 +624,7 @@ static int Open( vlc_object_t *p_this )
                 p_sys->i_ts_read = 1500 / p_sys->i_packet_size;
             }
             p_sys->buffer = malloc( p_sys->i_packet_size * p_sys->i_ts_read );
+            assert( p_sys->buffer );
             msg_Info( p_demux, "%s raw stream to file `%s' reading packets %d",
                       b_append ? "appending" : "dumping", p_sys->psz_file,
                       p_sys->i_ts_read );
@@ -3018,7 +3024,9 @@ static void EITCallBack( demux_t *p_demux,
                         {
                             msg_Dbg( p_demux, "       - text='%s'", psz_text );
 
-                            psz_extra = realloc( psz_extra, strlen(psz_extra) + strlen(psz_text) + 1 );
+                            psz_extra = realloc_or_free( psz_extra,
+                                   strlen(psz_extra) + strlen(psz_text) + 1 );
+                            assert( psz_extra );
                             strcat( psz_extra, psz_text );
                             free( psz_text );
                         }
@@ -3034,7 +3042,10 @@ static void EITCallBack( demux_t *p_demux,
                         {
                             msg_Dbg( p_demux, "       - desc='%s' item='%s'", psz_dsc, psz_itm );
 #if 0
-                            psz_extra = realloc( psz_extra, strlen(psz_extra) + strlen(psz_dsc) + strlen(psz_itm) + 3 + 1 );
+                            psz_extra = realloc_or_free( psz_extra,
+                                         strlen(psz_extra) + strlen(psz_dsc) +
+                                         strlen(psz_itm) + 3 + 1 );
+                            assert( psz_extra );
                             strcat( psz_extra, "(" );
                             strcat( psz_extra, psz_dsc );
                             strcat( psz_extra, " " );
index 97a7282093beac13906a1a7d0c14cf6d05bc17e5..4c12222e5bb4d76c22a4126ca2ae909f9a373df6 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_memory.h>
 
 #include <errno.h>
 #include <sys/types.h>
@@ -152,10 +155,12 @@ static int Open ( vlc_object_t *p_this )
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    assert( p_sys );
     p_sys->i_length = 0;
     p_sys->p_vobsub_stream = NULL;
     p_sys->i_tracks = 0;
     p_sys->track = (vobsub_track_t *)malloc( sizeof( vobsub_track_t ) );
+    assert( p_sys->track );
     p_sys->i_original_frame_width = -1;
     p_sys->i_original_frame_height = -1;
     p_sys->b_palette = false;
@@ -522,7 +527,9 @@ static int ParseVobSubIDX( demux_t *p_demux )
                         language, &i_track_id ) == 2 )
             {
                 p_sys->i_tracks++;
-                p_sys->track = realloc( p_sys->track, sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
+                p_sys->track = realloc_or_free( p_sys->track,
+                          sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
+                assert( p_sys->track );
                 language[2] = '\0';
 
                 /* Init the track */
@@ -531,6 +538,7 @@ static int ParseVobSubIDX( demux_t *p_demux )
                 current_tk->i_current_subtitle = 0;
                 current_tk->i_subtitles = 0;
                 current_tk->p_subtitles = malloc( sizeof( subtitle_t ) );;
+                assert( current_tk->p_subtitles );
                 current_tk->i_track_id = i_track_id;
                 current_tk->i_delay = (int64_t)0;
 
@@ -581,7 +589,10 @@ static int ParseVobSubIDX( demux_t *p_demux )
                 i_location = loc;
 
                 current_tk->i_subtitles++;
-                current_tk->p_subtitles = realloc( current_tk->p_subtitles, sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) );
+                current_tk->p_subtitles =
+                    realloc_or_free( current_tk->p_subtitles,
+                      sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) );
+                assert( current_tk->p_subtitles );
                 current_sub = &current_tk->p_subtitles[current_tk->i_subtitles - 1];
 
                 current_sub->i_start = i_start * i_sign;
index ef775d1c285a8c9792beb78672a3365804994b0c..e066d03facefb27eb93f61eef9f4a9292902e8d9 100644 (file)
@@ -38,6 +38,7 @@
 #include <vlc_common.h>
 #include <vlc_interface.h>
 #include <vlc_vout.h>
+#include <vlc_memory.h>
 
 /*****************************************************************************
  * vout_sys_t: video output QNX method descriptor
@@ -316,16 +317,10 @@ static int QNXManage( vout_thread_t *p_vout )
 
         if( i_ev == Ph_RESIZE_MSG )
         {
-            PhEvent_t *buf;
-
             i_buflen = PhGetMsgSize( p_event );
-            buf = realloc( p_event, i_buflen );
-            if( buf == NULL )
-            {
-                free( p_event );
+            p_event = realloc_or_free( p_event, i_buflen );
+            if( p_event == NULL )
                 return( 1 );
-            }
-            p_event = buf;
         }
         else if( i_ev == Ph_EVENT_MSG )
         {
index fb690fa7e2a4dda79dcfbd9b16e79af6fed7188a..e6090cac54785116528dccfe418a4f53b720177a 100644 (file)
@@ -31,6 +31,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_osd.h>
@@ -40,6 +42,7 @@
 #include <vlc_input.h>
 #include <vlc_strings.h>
 #include <vlc_dialog.h>
+#include <vlc_memory.h>
 
 #include <math.h>
 #include <errno.h>
@@ -360,6 +363,7 @@ static int Create( vlc_object_t *p_this )
      * current contribs. So just tell default windows font directory
      * is the place to search fonts
      */
+    assert( path );
     GetWindowsDirectory( path, PATH_MAX + 1 );
     strcat( path, "\\fonts" );
     if( p_dialog )
@@ -1673,15 +1677,16 @@ static void SetupLine( filter_t *p_filter, const char *psz_text_in,
     {
         (*pi_runs)++;
 
+        /* XXX this logic looks somewhat broken */
+
         if( *ppp_styles )
         {
-            *ppp_styles = (ft_style_t **)
-                realloc( *ppp_styles, *pi_runs * sizeof( ft_style_t * ) );
+            *ppp_styles = realloc_or_free( *ppp_styles,
+                                          *pi_runs * sizeof( ft_style_t * ) );
         }
         else if( *pi_runs == 1 )
         {
-            *ppp_styles = (ft_style_t **)
-                malloc( *pi_runs * sizeof( ft_style_t * ) );
+            *ppp_styles = malloc( *pi_runs * sizeof( ft_style_t * ) );
         }
 
         /* We have just malloc'ed this memory successfully -
@@ -1692,10 +1697,12 @@ static void SetupLine( filter_t *p_filter, const char *psz_text_in,
             p_style = NULL;
         }
 
+        /* XXX more iffy logic */
+
         if( *ppi_run_lengths )
         {
-            *ppi_run_lengths = (uint32_t *)
-                realloc( *ppi_run_lengths, *pi_runs * sizeof( uint32_t ) );
+            *ppi_run_lengths = realloc_or_free( *ppi_run_lengths,
+                                              *pi_runs * sizeof( uint32_t ) );
         }
         else if( *pi_runs == 1 )
         {
index cddaab7127c59f54f1e342d52b799bfd4c49f055..dc0f35496f86c2c5ee8046e46964fa03b48edd1c 100644 (file)
@@ -22,6 +22,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#include <vlc_memory.h>
+
 typedef struct font_stack_t font_stack_t;
 struct font_stack_t
 {
@@ -442,8 +444,7 @@ static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs,
 
                 if( *ppi_k_durations )
                 {
-                    *ppi_k_durations = (uint32_t *)
-                        realloc( *ppi_k_durations,
+                    *ppi_k_durations = realloc_or_free( *ppi_k_durations,
                                  *pi_k_runs * sizeof( uint32_t ) );
                 }
                 else if( *pi_k_runs == 1 )
@@ -454,8 +455,7 @@ static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs,
 
                 if( *ppi_k_run_lengths )
                 {
-                    *ppi_k_run_lengths = (uint32_t *)
-                        realloc( *ppi_k_run_lengths,
+                    *ppi_k_run_lengths = realloc_or_free( *ppi_k_run_lengths,
                                  *pi_k_runs * sizeof( uint32_t ) );
                 }
                 else if( *pi_k_runs == 1 )
index 668fd80b78b569446eadb360e7a882f29c9bd046..de4b6ea82fe7dd1dab56cdf7623461f4c9310a00 100644 (file)
@@ -36,6 +36,7 @@
 #include <vlc_xml.h>
 #include <vlc_block.h>
 #include <vlc_stream.h>
+#include <vlc_memory.h>
 
 #include <ctype.h>
 #include <stdarg.h>
@@ -174,7 +175,7 @@ static void CatalogAdd( xml_t *p_xml, const char *psz_arg1,
 static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
 {
     xml_reader_t *p_reader;
-    char *p_buffer, *p_new;
+    char *p_buffer;
     int i_size, i_pos = 0, i_buffer = 2048;
     XTag *p_root;
 
@@ -187,13 +188,9 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
     {
         i_pos += i_size;
         i_buffer += i_size;
-        p_new = realloc( p_buffer, i_buffer );
-        if( !p_new )
-        {
-            free( p_buffer );
+        p_buffer = realloc_or_free( p_buffer, i_buffer );
+        if( !p_buffer )
             return NULL;
-        }
-        p_buffer = p_new;
     }
     if( i_pos + i_size == 0 )
     {
@@ -355,6 +352,7 @@ static XList *xlist_append( XList *list, void *data )
     XList *l, *last;
 
     l = (XList *)malloc( sizeof(XList) );
+    assert( l );
     l->prev = l->next = NULL;
     l->data = data;
 
@@ -460,6 +458,7 @@ static char *xtag_slurp_to( XTagParser *parser, int good_end, int bad_end )
     if( xi > 0 && xtag_cin (s[xi], good_end) )
     {
         ret = malloc( xi+1 );
+        assert( ret );
         strncpy( ret, s, xi );
         ret[xi] = '\0';
         parser->start = &s[xi];
@@ -513,6 +512,7 @@ static char *xtag_slurp_quoted( XTagParser *parser )
     }
 
     ret = malloc( xi+1 );
+    assert( ret );
     strncpy( ret, s, xi );
     ret[xi] = '\0';
     parser->start = &s[xi];
@@ -565,6 +565,7 @@ static XAttribute *xtag_parse_attribute( XTagParser *parser )
     }
 
     attr = malloc( sizeof (*attr) );
+    assert( attr );
     attr->name = name;
     attr->value = value;
     return attr;
@@ -639,6 +640,7 @@ static XTag *xtag_parse_tag( XTagParser *parser )
     if( (pcdata = xtag_slurp_to( parser, X_OPENTAG, X_NONE )) != NULL )
     {
         tag = malloc( sizeof(*tag) );
+        assert( tag );
         tag->name = NULL;
         tag->pcdata = pcdata;
         tag->parent = parser->current_tag;
@@ -693,6 +695,7 @@ static XTag *xtag_parse_tag( XTagParser *parser )
 #endif
 
     tag = malloc( sizeof(*tag) );
+    assert( tag );
     tag->name = name;
     tag->pcdata = NULL;
     tag->parent = parser->current_tag;
@@ -832,6 +835,7 @@ static XTag *xtag_new_parse( const char *s, int n )
         }
 
         wrapper = malloc( sizeof(XTag) );
+        assert( wrapper );
         wrapper->name = NULL;
         wrapper->pcdata = NULL;
         wrapper->parent = NULL;
index da6556ddb6f3eae61faa17680a116cbed241a552..31e6504998ecf84deef4e6c58cca705b2d31729a 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
 #include <vlc_codecs.h>
+#include <vlc_memory.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -482,8 +485,9 @@ static int Mux      ( sout_mux_t *p_mux )
             if( p_sys->idx1.i_entry_count >= p_sys->idx1.i_entry_max )
             {
                 p_sys->idx1.i_entry_max += 10000;
-                p_sys->idx1.entry = realloc( p_sys->idx1.entry,
-                                             p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) );
+                p_sys->idx1.entry = realloc_or_free( p_sys->idx1.entry,
+                       p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) );
+                assert( p_sys->idx1.entry );
             }
 
             p_data = block_Realloc( p_data, 8, p_data->i_buffer );
index d59c90d706144f5957536c4806dc7fa9a6b7bf47..13e72fa290e2a111d82f88732defe0dd4734f7e2 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
+#include <vlc_memory.h>
 
 #include <time.h>
 
@@ -597,9 +600,9 @@ again:
         if( p_stream->i_entry_count >= p_stream->i_entry_max - 1 )
         {
             p_stream->i_entry_max += 1000;
-            p_stream->entry =
-                realloc( p_stream->entry,
+            p_stream->entry = realloc_or_free( p_stream->entry,
                          p_stream->i_entry_max * sizeof( mp4_entry_t ) );
+            assert( p_stream->entry );
         }
 
         /* update */
@@ -1948,6 +1951,7 @@ static void bo_init( bo_t *p_bo, int i_size, uint8_t *p_buffer,
     {
         p_bo->i_buffer_size = __MAX( i_size, 1024 );
         p_bo->p_buffer = malloc( p_bo->i_buffer_size );
+        assert( p_bo->p_buffer );
     }
     else
     {
@@ -1968,8 +1972,8 @@ static void bo_add_8( bo_t *p_bo, uint8_t i )
     else if( p_bo->b_grow )
     {
         p_bo->i_buffer_size += 1024;
-        p_bo->p_buffer = realloc( p_bo->p_buffer, p_bo->i_buffer_size );
-
+        p_bo->p_buffer = realloc_or_free( p_bo->p_buffer, p_bo->i_buffer_size );
+        assert( p_bo->p_buffer );
         p_bo->p_buffer[p_bo->i_buffer] = i;
     }
 
index 7528059455567c4199f8dff9a9756edd8ebb8722..233c99714def96664e509e913e6580585bac7877 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
 #include <vlc_codecs.h>
+#include <vlc_memory.h>
 
 #include <ogg/ogg.h>
 
@@ -535,9 +538,9 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
         /* move input in delete queue */
         if( !p_stream->b_new )
         {
-            p_sys->pp_del_streams = realloc( p_sys->pp_del_streams,
-                                             (p_sys->i_del_streams + 1) *
-                                             sizeof(ogg_stream_t *) );
+            p_sys->pp_del_streams = realloc_or_free( p_sys->pp_del_streams,
+                        (p_sys->i_del_streams + 1) * sizeof(ogg_stream_t *) );
+            assert( p_sys->pp_del_streams );
             p_sys->pp_del_streams[p_sys->i_del_streams++] = p_stream;
         }
         else
index 7497c7cf6379135ae35bb10ec32dbb164223333b..91970408d7f7f3bdc286fbcf1820225fe069f46e 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_codec.h>
 #include <vlc_block.h>
+#include <vlc_memory.h>
 
 #include <vlc_bits.h>
 #include <vlc_block_helper.h>
@@ -157,6 +160,7 @@ static int Open( vlc_object_t *p_this )
         /* We have a vol */
         p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
         p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra );
+        assert( p_dec->fmt_out.p_extra );
         memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra,
                 p_dec->fmt_in.i_extra );
 
@@ -287,7 +291,8 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
         if( (size_t)p_dec->fmt_out.i_extra != p_frag->i_buffer )
         {
             p_dec->fmt_out.p_extra =
-                realloc( p_dec->fmt_out.p_extra, p_frag->i_buffer );
+                realloc_or_free( p_dec->fmt_out.p_extra, p_frag->i_buffer );
+            assert( p_dec->fmt_out.p_extra );
             p_dec->fmt_out.i_extra = p_frag->i_buffer;
         }
         memcpy( p_dec->fmt_out.p_extra, p_frag->p_buffer, p_frag->i_buffer );
index 9651bae992918928e28a7abaeba932504977b52c..7cbc47dc6abb459f3f12c8a437aafc3438cc349a 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_block.h>
+#include <vlc_memory.h>
 
 #include <vlc_bits.h>
 #include <vlc_block_helper.h>
@@ -138,6 +141,7 @@ static int Open( vlc_object_t *p_this )
     /* Create the output format */
     es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
     p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
+    assert( p_sys );
 
     packetizer_Init( &p_sys->packetizer,
                      p_vc1_startcode, sizeof(p_vc1_startcode),
@@ -309,7 +313,8 @@ static void BuildExtraData( decoder_t *p_dec )
     if( p_es->i_extra != i_extra )
     {
         p_es->i_extra = i_extra;
-        p_es->p_extra = realloc( p_dec->fmt_out.p_extra, p_es->i_extra );
+        p_es->p_extra = realloc_or_free( p_es->p_extra, p_es->i_extra );
+        assert( p_es->p_extra );
     }
     memcpy( p_es->p_extra,
             p_sys->sh.p_sh->p_buffer, p_sys->sh.p_sh->i_buffer );
index eefd8930a7b42e033d971974e5457214d52bbe23..60e45591bc584d5f4de9b02a2adcaa4c7add3746 100644 (file)
@@ -414,6 +414,7 @@ static int OpenDemux( vlc_object_t *p_this )
     if( p_sdp->psz_uri == NULL ) goto error;
 
     p_demux->p_sys = (demux_sys_t *)malloc( sizeof(demux_sys_t) );
+    assert( p_demux->p_sys );
     p_demux->p_sys->p_sdp = p_sdp;
     p_demux->pf_control = Control;
     p_demux->pf_demux = Demux;
index 8a675750272d737d6adc36ddb5f6948b1632bc7b..127634c4c15b83f2de07844dac41fd6ca9c4a1c1 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
+#include <vlc_memory.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -195,6 +198,7 @@ static int OpenOut( vlc_object_t *p_this )
                    p_stream->p_cfg );
 
     p_sys          = malloc( sizeof( out_sout_stream_sys_t ) );
+    assert( p_sys );
     p_sys->b_inited = false;
 
     var_Create( p_this->p_libvlc, "bridge-lock", VLC_VAR_MUTEX );
@@ -258,6 +262,7 @@ static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt )
     if ( p_bridge == NULL )
     {
         p_bridge = malloc( sizeof( bridge_t ) );
+        assert( p_bridge );
 
         var_Create( p_stream->p_libvlc, p_sys->psz_name, VLC_VAR_ADDRESS );
         var_SetAddress( p_stream->p_libvlc, p_sys->psz_name, p_bridge );
@@ -274,11 +279,12 @@ static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt )
 
     if ( i == p_bridge->i_es_num )
     {
-        p_bridge->pp_es = realloc( p_bridge->pp_es,
-                                   (p_bridge->i_es_num + 1)
-                                     * sizeof(bridged_es_t *) );
+        p_bridge->pp_es = realloc_or_free( p_bridge->pp_es,
+                          (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) );
+        assert( p_bridge->pp_es );
         p_bridge->i_es_num++;
         p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) );
+        assert( p_bridge->pp_es[i] );
     }
 
     p_sys->p_es = p_es = p_bridge->pp_es[i];
@@ -391,6 +397,7 @@ static int OpenIn( vlc_object_t *p_this )
     vlc_value_t val;
 
     p_sys          = malloc( sizeof( in_sout_stream_sys_t ) );
+    assert( p_sys );
 
     p_sys->p_out = sout_StreamNew( p_stream->p_sout, p_stream->psz_next );
     if( !p_sys->p_out )
index 30aab1aab01e0e47a66314b475477b980c1bc564..78117fef73ce55fa20aa95de22088b26ff48f3f4 100644 (file)
@@ -42,6 +42,8 @@
 #include <vlc_image.h>
 #include <vlc_filter.h>
 
+#include <vlc_memory.h>
+
 #include "../video_filter/mosaic.h"
 
 #include <assert.h>
@@ -362,6 +364,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         vlc_value_t val;
 
         p_bridge = malloc( sizeof( bridge_t ) );
+        assert( p_bridge );
 
         var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS );
         val.p_address = p_bridge;
@@ -379,11 +382,12 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 
     if ( i == p_bridge->i_es_num )
     {
-        p_bridge->pp_es = realloc( p_bridge->pp_es,
-                                   (p_bridge->i_es_num + 1)
-                                     * sizeof(bridged_es_t *) );
+        p_bridge->pp_es = realloc_or_free( p_bridge->pp_es,
+                          (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) );
+        assert( p_bridge->pp_es );
         p_bridge->i_es_num++;
         p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) );
+        assert( p_bridge->pp_es[i] );
     }
 
     p_sys->p_es = p_es = p_bridge->pp_es[i];
index f4cf3c48080cfa992284f6a05cfe5d7457f959b6..70a4e37868cb810f1761ddb792da288dcb828f7a 100644 (file)
@@ -42,6 +42,7 @@
 #include <vlc_gcrypt.h>
 #include <vlc_es.h>
 #include <vlc_http.h>
+#include <vlc_memory.h>
 
 #define RAOP_PORT 5000
 #define RAOP_USER_AGENT "VLC " VERSION
@@ -1299,7 +1300,7 @@ static void SendAudio( sout_stream_t *p_stream, block_t *p_buffer )
             /* Grow in blocks of 4K */
             i_realloc_len = (1 + (i_len / 4096)) * 4096;
 
-            p_sys->p_sendbuf = realloc( p_sys->p_sendbuf, i_realloc_len );
+            p_sys->p_sendbuf = realloc_or_free( p_sys->p_sendbuf, i_realloc_len );
             if ( p_sys->p_sendbuf == NULL )
                 goto error;
 
index 269fed2cc21252b8003c60378d34b56ccbc5b0f8..2ca709a30a16d2899defe34f91d4f13feea2b77d 100644 (file)
@@ -38,6 +38,8 @@
 #include <vlc_image.h>
 #include <vlc_osd.h>
 
+#include <vlc_memory.h>
+
 #ifdef LoadImage
 #   undef LoadImage
 #endif
@@ -940,7 +942,9 @@ void parse_i_values( BarGraph_t *p_BarGraph, char *i_values)
     res = strtok_r(i_values, delim, &tok);
     while (res != NULL) {
         p_BarGraph->nbChannels++;
-        p_BarGraph->i_values = (int*)realloc(p_BarGraph->i_values, p_BarGraph->nbChannels*sizeof(int));
+        p_BarGraph->i_values = realloc_or_free(p_BarGraph->i_values,
+                                          p_BarGraph->nbChannels*sizeof(int));
+        assert(p_BarGraph->i_values);
         p_BarGraph->i_values[p_BarGraph->nbChannels-1] = __MAX( __MIN( atof(res)*p_BarGraph->scale, p_BarGraph->scale ), 0 );
         res = strtok_r(NULL, delim, &tok);
     }
index 575342980315fdf8c994197999e7a5b9b5a72ec6..d889b540c9a8a30b1de51ef0f439bdf1febc7487 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_filter.h>
+#include <vlc_memory.h>
 
 #define BLUESCREEN_HELP N_( \
     "This effect, also known as \"greenscreen\" or \"chroma key\" blends " \
@@ -185,7 +188,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         return NULL;
     }
 
-    p_sys->p_at = realloc( p_sys->p_at, i_lines * i_pitch * sizeof( uint8_t ) );
+    p_sys->p_at = realloc_or_free( p_sys->p_at,
+                                   i_lines * i_pitch * sizeof( uint8_t ) );
+    assert( p_sys->p_at );
     p_at = p_sys->p_at;
 
     vlc_mutex_lock( &p_sys->lock );
index 477815a6dfda7e603f3eb9cca9db360552ea3c39..06d4170c8798d351fbdaa672e18f8a25a2d58d7d 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <vlc_common.h>
 #include <vlc_osd.h>
+#include <vlc_memory.h>
 
 #include <fcntl.h>
 #include "dynamicoverlay.h"
@@ -80,8 +81,8 @@ ssize_t ListAdd( list_t *p_list, overlay_t *p_new )
     /* Have to expand */
     size_t i_size = p_list->pp_tail - p_list->pp_head;
     size_t i_newsize = i_size * 2;
-    p_list->pp_head = realloc( p_list->pp_head,
-                               i_newsize * sizeof( overlay_t * ) );
+    p_list->pp_head = realloc_or_free( p_list->pp_head,
+                                       i_newsize * sizeof( overlay_t * ) );
     if( p_list->pp_head == NULL )
         return VLC_ENOMEM;
 
index daee2a115dbb380a4cb86ade22541428f2ea9a26..48dc7f96feeb3133b5f7d650067f233bb556529d 100644 (file)
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_memory.h>
 
 #include <vlc_filter.h>
 #include "filter_picture.h"
@@ -102,6 +105,8 @@ static void gaussianblur_InitDistribution( filter_sys_t *p_sys )
     type_t *pt_distribution = malloc( (2*i_dim+1) * sizeof( type_t ) );
     int x;
 
+    assert( pt_distribution );
+
     for( x = -i_dim; x <= i_dim; x++ )
     {
         const float f_distribution = sqrt( exp(-(x*x)/(f_sigma*f_sigma) ) / (2.*M_PI*f_sigma*f_sigma) );
@@ -199,10 +204,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     }
     if( !p_sys->pt_buffer )
     {
-        p_sys->pt_buffer = realloc( p_sys->pt_buffer,
-                                    p_pic->p[Y_PLANE].i_visible_lines *
-                                        p_pic->p[Y_PLANE].i_pitch *
-                                        sizeof( type_t ) );
+        p_sys->pt_buffer = realloc_or_free( p_sys->pt_buffer,
+                               p_pic->p[Y_PLANE].i_visible_lines *
+                               p_pic->p[Y_PLANE].i_pitch * sizeof( type_t ) );
     }
 
     pt_buffer = p_sys->pt_buffer;
@@ -215,6 +219,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 
         p_sys->pt_scale = malloc( i_visible_lines * i_pitch * sizeof( type_t ) );
         pt_scale = p_sys->pt_scale;
+        assert( pt_scale );
 
         for( i_line = 0 ; i_line < i_visible_lines ; i_line++ )
         {
index 1100d22751acc81fb9d24f9379902d04b8287022..ea47c41eec8b686fa82e4f138f021ea9dc4eaddd 100644 (file)
 
 #include <math.h>
 #include <limits.h> /* INT_MAX */
+#include <assert.h>
 
 #include <vlc_filter.h>
 #include <vlc_image.h>
 
+#include <vlc_memory.h>
+
 #include "mosaic.h"
 
 #define BLANK_DELAY INT64_C(1000000)
@@ -254,14 +257,16 @@ static void __mosaic_ParseSetOffsets( vlc_object_t *p_this,
         {
             i_index++;
 
-            p_sys->pi_x_offsets =
-                realloc( p_sys->pi_x_offsets, i_index * sizeof(int) );
+            p_sys->pi_x_offsets = realloc_or_free( p_sys->pi_x_offsets,
+                                                   i_index * sizeof(int) );
+            assert( p_sys->pi_x_offsets );
             p_sys->pi_x_offsets[i_index - 1] = atoi( psz_offsets );
             psz_end = strchr( psz_offsets, ',' );
             psz_offsets = psz_end + 1;
 
-            p_sys->pi_y_offsets =
-                realloc( p_sys->pi_y_offsets, i_index * sizeof(int) );
+            p_sys->pi_y_offsets = realloc_or_free( p_sys->pi_y_offsets,
+                                                   i_index * sizeof(int) );
+            assert( p_sys->pi_y_offsets );
             p_sys->pi_y_offsets[i_index - 1] = atoi( psz_offsets );
             psz_end = strchr( psz_offsets, ',' );
             psz_offsets = psz_end + 1;
@@ -359,8 +364,9 @@ static int CreateFilter( vlc_object_t *p_this )
         {
             psz_end = strchr( psz_order, ',' );
             i_index++;
-            p_sys->ppsz_order = realloc( p_sys->ppsz_order,
-                                         i_index * sizeof(char *) );
+            p_sys->ppsz_order = realloc_or_free( p_sys->ppsz_order,
+                                                 i_index * sizeof(char *) );
+            assert( p_sys->ppsz_order );
             p_sys->ppsz_order[i_index - 1] = strndup( psz_order,
                                            psz_end - psz_order );
             psz_order = psz_end+1;
@@ -876,8 +882,9 @@ static int MosaicCallback( vlc_object_t *p_this, char const *psz_var,
             {
                 psz_end = strchr( psz_order, ',' );
                 i_index++;
-                p_sys->ppsz_order = realloc( p_sys->ppsz_order,
-                                    i_index * sizeof(char *) );
+                p_sys->ppsz_order = realloc_or_free( p_sys->ppsz_order,
+                                                   i_index * sizeof(char *) );
+                assert( p_sys->ppsz_order );
                 p_sys->ppsz_order[i_index - 1] = strndup( psz_order,
                                            psz_end - psz_order );
                 psz_order = psz_end+1;
index 98164fc0c3d9043eca48daa03bc413caabd433d6..b9a080b7af8acb30e7f5b6f19c65cf34e9ca0cc6 100644 (file)
@@ -35,6 +35,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 
@@ -48,6 +50,8 @@
 
 #include <vlc_image.h>
 
+#include <vlc_memory.h>
+
 #include <time.h>
 
 /*****************************************************************************
@@ -706,8 +710,9 @@ static bool ParseFeed( filter_t *p_filter, xml_reader_t *p_xml_reader,
             {
                 b_is_item = true;
                 p_feed->i_items++;
-                p_feed->p_items = realloc( p_feed->p_items,
-                                           p_feed->i_items * sizeof( rss_item_t ) );
+                p_feed->p_items = realloc_or_free( p_feed->p_items,
+                                     p_feed->i_items * sizeof( rss_item_t ) );
+                assert( p_feed->p_items );
                 p_feed->p_items[p_feed->i_items-1].psz_title = NULL;
                 p_feed->p_items[p_feed->i_items-1].psz_description = NULL;
                 p_feed->p_items[p_feed->i_items-1].psz_link = NULL;
index 678e7e7e40acf84d6b362c0c09a417116aa0d244..c2a1fa552c8f5aef7a76af3ba83cd26109277674 100644 (file)
@@ -42,6 +42,7 @@
 #include <vlc_plugin.h>
 #include <vlc_vout.h>
 #include <vlc_playlist.h>   /* needed for wallpaper */
+#include <vlc_memory.h>
 
 #include <ddraw.h>
 #include <commctrl.h>       /* ListView_(Get|Set)* */
@@ -1817,12 +1818,12 @@ BOOL WINAPI DirectXEnumCallback2( GUID* p_guid, LPTSTR psz_desc,
 
     module_config_t *p_item = (module_config_t *)p_context;
 
-    p_item->ppsz_list =
-        (char **)realloc( p_item->ppsz_list,
+    p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
                           (p_item->i_list+2) * sizeof(char *) );
-    p_item->ppsz_list_text =
-        (char **)realloc( p_item->ppsz_list_text,
+    assert( p_item->ppsz_list );
+    p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
                           (p_item->i_list+2) * sizeof(char *) );
+    assert( p_item->ppsz_list_text );
 
     p_item->ppsz_list[p_item->i_list] = strdup( psz_drivername );
     p_item->ppsz_list_text[p_item->i_list] = NULL;