From 318e9b862b1792bee23521a459ca44ef1e40f7ed Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Sat, 7 Oct 2006 23:14:58 +0000 Subject: [PATCH] * Fixed a bunch of memory leaks. --- modules/demux/mp4/libmp4.c | 11 +++++++++-- modules/demux/playlist/playlist.c | 2 +- modules/demux/playlist/playlist.h | 3 ++- modules/demux/playlist/xspf.c | 8 +++++++- modules/misc/xml/libxml.c | 7 ++----- src/input/input.c | 4 ++-- src/video_output/vout_subpictures.c | 5 ++--- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c index 6c282ead39..4bb335f1fd 100644 --- a/modules/demux/mp4/libmp4.c +++ b/modules/demux/mp4/libmp4.c @@ -957,8 +957,11 @@ static int MP4_ReadBox_avcC( stream_t *p_stream, MP4_Box_t *p_box ) p_avcC = p_box->data.p_avcC; p_avcC->i_avcC = i_read; - p_avcC->p_avcC = malloc( p_avcC->i_avcC ); - memcpy( p_avcC->p_avcC, p_peek, i_read ); + if( p_avcC->i_avcC > 0 ) + { + p_avcC->p_avcC = malloc( p_avcC->i_avcC ); + memcpy( p_avcC->p_avcC, p_peek, i_read ); + } MP4_GET1BYTE( p_avcC->i_version ); MP4_GET1BYTE( p_avcC->i_profile ); @@ -1030,6 +1033,8 @@ static void MP4_FreeBox_avcC( MP4_Box_t *p_box ) MP4_Box_data_avcC_t *p_avcC = p_box->data.p_avcC; int i; + if( p_avcC->i_avcC > 0 ) FREENULL( p_avcC->p_avcC ); + for( i = 0; i < p_avcC->i_sps; i++ ) { FREENULL( p_avcC->sps[i] ); @@ -1039,7 +1044,9 @@ static void MP4_FreeBox_avcC( MP4_Box_t *p_box ) FREENULL( p_avcC->pps[i] ); } if( p_avcC->i_sps > 0 ) FREENULL( p_avcC->sps ); + if( p_avcC->i_sps > 0 ) FREENULL( p_avcC->i_sps_length ); if( p_avcC->i_pps > 0 ) FREENULL( p_avcC->pps ); + if( p_avcC->i_pps > 0 ) FREENULL( p_avcC->i_pps_length ); } static int MP4_ReadBox_sample_soun( stream_t *p_stream, MP4_Box_t *p_box ) diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c index f2acf2ddc4..5d991178c9 100644 --- a/modules/demux/playlist/playlist.c +++ b/modules/demux/playlist/playlist.c @@ -85,7 +85,7 @@ vlc_module_begin(); set_description( _("XSPF playlist import") ); add_shortcut( "xspf-open" ); set_capability( "demux2", 10 ); - set_callbacks( E_(xspf_import_Activate), NULL ); + set_callbacks( E_(Import_xspf),E_(Close_xspf) ); add_submodule(); set_description( _("New winamp 5.2 shoutcast import") ); add_shortcut( "shout-winamp" ); diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h index 14983004c2..4e643b8542 100644 --- a/modules/demux/playlist/playlist.h +++ b/modules/demux/playlist/playlist.h @@ -48,7 +48,8 @@ void E_(Close_DVB) ( vlc_object_t * ); int E_(Import_podcast) ( vlc_object_t * ); void E_(Close_podcast) ( vlc_object_t * ); -int E_(xspf_import_Activate) ( vlc_object_t * ); +int E_(Import_xspf) ( vlc_object_t * ); +void E_(Close_xspf) ( vlc_object_t * ); int E_(Import_Shoutcast) ( vlc_object_t * ); void E_(Close_Shoutcast) ( vlc_object_t * ); diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c index 442294bf81..9c8a49c31b 100644 --- a/modules/demux/playlist/xspf.c +++ b/modules/demux/playlist/xspf.c @@ -51,13 +51,19 @@ static int Demux( demux_t * ); /** * \brief XSPF submodule initialization function */ -int E_(xspf_import_Activate)( vlc_object_t *p_this ) +int E_(Import_xspf)( vlc_object_t *p_this ) { DEMUX_BY_EXTENSION_OR_FORCED_MSG( ".xspf", "xspf-open", "using XSPF playlist reader" ); return VLC_SUCCESS; } +void E_(Close_xspf)( vlc_object_t *p_this ) +{ + demux_t *p_demux = (demux_t *)p_this; + free( p_demux->p_sys ); +} + /** * \brief demuxer function for XSPF parsing */ diff --git a/modules/misc/xml/libxml.c b/modules/misc/xml/libxml.c index 4387b1c03c..84ef82de24 100644 --- a/modules/misc/xml/libxml.c +++ b/modules/misc/xml/libxml.c @@ -120,9 +120,6 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *p_stream ) xml_reader_t *p_reader; xml_reader_sys_t *p_sys; xmlTextReaderPtr p_libxml_reader; - xmlParserInputBufferPtr p_read_context; - - p_read_context = malloc( sizeof( xmlParserInputBuffer ) ); p_libxml_reader = xmlReaderForIO( StreamRead, NULL, p_stream, NULL, NULL, 0 ); @@ -216,7 +213,7 @@ static char *ReaderName( xml_reader_t *p_reader ) const xmlChar *psz_name = xmlTextReaderConstName( p_reader->p_sys->p_reader ); - if( psz_name ) return strdup( psz_name ); + if( psz_name ) return strdup( (const char *)psz_name ); else return 0; } @@ -225,7 +222,7 @@ static char *ReaderValue( xml_reader_t *p_reader ) const xmlChar *psz_value = xmlTextReaderConstValue( p_reader->p_sys->p_reader ); - if( psz_value ) return strdup( psz_value ); + if( psz_value ) return strdup( (const char *)psz_value ); else return 0; } diff --git a/src/input/input.c b/src/input/input.c index 6965789770..81c17410fc 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -1970,8 +1970,8 @@ static int InputSourceInit( input_thread_t *p_input, { psz_path = psz_mrl; msg_Dbg( p_input, "trying to pre-parse %s", psz_path ); - psz_demux = strdup( "" ); - psz_access = strdup( "file" ); + psz_demux = ""; + psz_access = "file"; } if( in->p_demux ) diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c index cb75b68efe..b43ea11b49 100644 --- a/src/video_output/vout_subpictures.c +++ b/src/video_output/vout_subpictures.c @@ -98,7 +98,6 @@ spu_t *__spu_Create( vlc_object_t *p_this ) */ int spu_Init( spu_t *p_spu ) { - char *psz_filter; char *psz_parser; vlc_value_t val; @@ -110,8 +109,7 @@ int spu_Init( spu_t *p_spu ) var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Get( p_spu, "sub-filter", &val ); - psz_filter = val.psz_string; - psz_parser = psz_filter; + psz_parser = val.psz_string; while( psz_parser && *psz_parser ) { @@ -153,6 +151,7 @@ int spu_Init( spu_t *p_spu ) free( psz_name ); } + if( val.psz_string ) free( val.psz_string ); return VLC_EGENERIC; } -- 2.39.2