Commit 15643af1 authored by JP Dinger's avatar JP Dinger

Replace argument = realloc( argument, size ); with realloc_or_free() in...

Replace argument = realloc( argument, size ); with realloc_or_free() in modules/*, and while at it add assert( argument ) to mark unhandled ENOMEM conditions, also for malloc().
parent 4e472031
......@@ -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();
......
......@@ -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';
......
......@@ -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++)
{
......
......@@ -29,7 +29,10 @@
# 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 );
......
......@@ -29,10 +29,13 @@
# 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 );
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -30,14 +30,15 @@
# 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,
......
......@@ -28,12 +28,16 @@
# 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;
}
......
......@@ -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++;
......
......@@ -30,10 +30,13 @@
# 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];
......
......@@ -36,7 +36,7 @@
#include "xarray.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h> /* realloc() */
# include <stdlib.h> /* malloc() */
#endif
#undef HISTORY_DEBUG
......
......@@ -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; \
}
......
......@@ -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 );
}
......
......@@ -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;
}
......
......@@ -30,10 +30,13 @@
# 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 );
......