[vlc-devel] commit: Fix potential memleaks (CID 58 and 59) ( Rémi Duraffort )
git version control
git at videolan.org
Wed Oct 8 22:27:34 CEST 2008
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Oct 8 22:26:44 2008 +0200| [9ccd884adbfde533830ba5eb3a1e5bb268ac036b] | committer: Rémi Duraffort
Fix potential memleaks (CID 58 and 59)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9ccd884adbfde533830ba5eb3a1e5bb268ac036b
---
modules/visualization/visual/effects.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/modules/visualization/visual/effects.c b/modules/visualization/visual/effects.c
index 6566f4f..f561f5d 100644
--- a/modules/visualization/visual/effects.c
+++ b/modules/visualization/visual/effects.c
@@ -96,16 +96,13 @@ int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
(float*)p_buffer->p_buffer;
int16_t *p_buffs; /* int16_t converted buffer */
- int16_t *p_s16_buff = NULL; /* int16_t converted buffer */
+ int16_t *p_s16_buff; /* int16_t converted buffer */
- p_s16_buff = (int16_t*)malloc(
+ p_s16_buff = malloc(
p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(int16_t));
if( !p_s16_buff )
- {
- msg_Err(p_aout,"out of memory");
return -1;
- }
p_buffs = p_s16_buff;
i_nb_bands = config_GetInt ( p_aout, "visual-nbbands" );
@@ -125,10 +122,10 @@ int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
if( !p_effect->p_data )
{
- p_effect->p_data=(void *)malloc(i_nb_bands * sizeof(int) );
+ p_effect->p_data = malloc(i_nb_bands * sizeof(int) );
if( !p_effect->p_data)
{
- msg_Err(p_aout,"out of memory");
+ free( p_s16_buff );
return -1;
}
peaks = (int *)p_effect->p_data;
@@ -144,10 +141,10 @@ int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
}
- height = (int *)malloc( i_nb_bands * sizeof(int) );
- if( !height)
+ height = malloc( i_nb_bands * sizeof(int) );
+ if( !height )
{
- msg_Err(p_aout,"out of memory");
+ free( p_s16_buff );
return -1;
}
/* Convert the buffer to int16_t */
@@ -165,6 +162,8 @@ int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
p_state = visual_fft_init();
if( !p_state)
{
+ free( height );
+ free( p_s16_buff );
msg_Err(p_aout,"unable to initialize FFT transform");
return -1;
}
More information about the vlc-devel
mailing list