[vlc-devel] commit: Fix potential memleaks. ( Rémi Duraffort )
git version control
git at videolan.org
Wed Aug 20 20:10:49 CEST 2008
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Aug 20 20:13:39 2008 +0200| [6aa9a2b168c7bc68de7f5c751cc9a642b990b388] | committer: Rémi Duraffort
Fix potential memleaks.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6aa9a2b168c7bc68de7f5c751cc9a642b990b388
---
modules/audio_filter/normvol.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/modules/audio_filter/normvol.c b/modules/audio_filter/normvol.c
index 0c57c0b..8b9f342 100644
--- a/modules/audio_filter/normvol.c
+++ b/modules/audio_filter/normvol.c
@@ -131,6 +131,8 @@ static int Open( vlc_object_t *p_this )
i_channels = aout_FormatNbChannels( &p_filter->input );
p_sys = p_filter->p_sys = malloc( sizeof( aout_filter_sys_t ) );
+ if( !p_sys )
+ return VLC_ENOMEM;
p_sys->i_nb = var_CreateGetInteger( p_filter->p_parent, "norm-buff-size" );
p_sys->f_max = var_CreateGetFloat( p_filter->p_parent, "norm-max-level" );
@@ -139,6 +141,11 @@ static int Open( vlc_object_t *p_this )
/* We need to store (nb_buffers+1)*nb_channels floats */
p_sys->p_last = malloc( sizeof( float ) * (i_channels) *
(p_filter->p_sys->i_nb + 2) );
+ if( !p_sys->p_last )
+ {
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
memset( p_sys->p_last, 0 ,sizeof( float ) * (i_channels) *
(p_filter->p_sys->i_nb + 2) );
return VLC_SUCCESS;
@@ -162,10 +169,17 @@ static int Open( vlc_object_t *p_this )
struct aout_filter_sys_t *p_sys = p_filter->p_sys;
- pf_sum = (float *)malloc( sizeof(float) * i_channels );
+ pf_sum = malloc( sizeof(float) * i_channels );
+ if( !pf_sum )
+ return;
memset( pf_sum, 0, sizeof(float) * i_channels );
- pf_gain = (float *)malloc( sizeof(float) * i_channels );
+ pf_gain = malloc( sizeof(float) * i_channels );
+ if( !pf_gain )
+ {
+ free( pf_sum );
+ return;
+ }
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
More information about the vlc-devel
mailing list