From 3059bd8f642dc7009306c9dca9ce18c565b1964e Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Duraffort?= Date: Wed, 20 Aug 2008 22:45:24 +0200 Subject: [PATCH] Check malloc return value. --- modules/meta_engine/taglib.cpp | 15 +++++++++------ modules/mux/asf.c | 6 ++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp index e6b288d50e..b125966f58 100644 --- a/modules/meta_engine/taglib.cpp +++ b/modules/meta_engine/taglib.cpp @@ -299,12 +299,15 @@ static int ReadMeta( vlc_object_t *p_this ) * terminated string */ char *psz_ufid = (char*) malloc( 64 ); int j = 0; - while( ( j < 63 ) && - ( j < p_ufid->identifier().size() ) ) - psz_ufid[j] = p_ufid->identifier()[j++]; - psz_ufid[j] = '\0'; - vlc_meta_SetTrackID( p_meta, psz_ufid ); - free( psz_ufid ); + if( psz_ufid ) + { + while( ( j < 63 ) && + ( j < p_ufid->identifier().size() ) ) + psz_ufid[j] = p_ufid->identifier()[j++]; + psz_ufid[j] = '\0'; + vlc_meta_SetTrackID( p_meta, psz_ufid ); + free( psz_ufid ); + } } } diff --git a/modules/mux/asf.c b/modules/mux/asf.c index f2c3c8c861..fbcc6081fd 100644 --- a/modules/mux/asf.c +++ b/modules/mux/asf.c @@ -201,6 +201,8 @@ static int Open( vlc_object_t *p_this ) p_mux->pf_mux = Mux; p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) ); + if( !p_sys ) + return VLC_ENOMEM; p_sys->b_asf_http = p_mux->psz_mux && !strcmp( p_mux->psz_mux, "asfh" ); if( p_sys->b_asf_http ) { @@ -449,6 +451,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) tk->i_extra = sizeof( WAVEFORMATEX ) + p_input->p_fmt->i_extra + i_extra; tk->p_extra = malloc( tk->i_extra ); + if( !tk->p_extra ) + return VLC_ENOMEM; bo_init( &bo, tk->p_extra, tk->i_extra ); bo_addle_u16( &bo, tk->i_tag ); bo_addle_u16( &bo, p_input->p_fmt->audio.i_channels ); @@ -506,6 +510,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) tk->i_extra = 11 + sizeof( BITMAPINFOHEADER ) + p_input->p_fmt->i_extra; tk->p_extra = malloc( tk->i_extra ); + if( !tk->p_extra ) + return VLC_ENOMEM; bo_init( &bo, tk->p_extra, tk->i_extra ); bo_addle_u32( &bo, p_input->p_fmt->video.i_width ); bo_addle_u32( &bo, p_input->p_fmt->video.i_height ); -- 2.39.2