[vlc-devel] commit: Check malloc return value. ( Rémi Duraffort )
git version control
git at videolan.org
Wed Aug 20 23:19:35 CEST 2008
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Aug 20 22:45:24 2008 +0200| [3059bd8f642dc7009306c9dca9ce18c565b1964e] | committer: Rémi Duraffort
Check malloc return value.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3059bd8f642dc7009306c9dca9ce18c565b1964e
---
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 e6b288d..b125966 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 f2c3c8c..fbcc608 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 );
More information about the vlc-devel
mailing list