[vlc-devel] [PATCH] visual: check for NULL before free

Edward Wang edward.c.wang at compdigitec.com
Sun May 27 01:04:57 CEST 2012


Close #6879
---
 modules/visualization/visual/visual.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index 964924c..a91faa7 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -373,20 +373,23 @@ static void Close( vlc_object_t *p_this )
     for( int i = 0; i < p_sys->i_effect; i++ )
     {
 #define p_effect p_sys->effect[i]
-        if( !strncmp( p_effect->psz_name, "spectrum", strlen( "spectrum" ) ) )
+        if( p_effect->p_data != NULL )
         {
-            spectrum_data *p_data = p_effect->p_data;
-            free( p_data->peaks );
-            free( p_data->prev_heights );
-            free( p_data->p_prev_s16_buff );
-        }
-        if( !strncmp( p_effect->psz_name, "spectrometer", strlen( "spectrometer" ) ) )
-        {
-            spectrometer_data *p_data = p_effect->p_data;
-            free( p_data->peaks );
-            free( p_data->p_prev_s16_buff );
+            if( !strncmp( p_effect->psz_name, "spectrum", strlen( "spectrum" ) ) )
+            {
+                spectrum_data* p_data = p_effect->p_data;
+                free( p_data->peaks );
+                free( p_data->prev_heights );
+                free( p_data->p_prev_s16_buff );
+            }
+            if( !strncmp( p_effect->psz_name, "spectrometer", strlen( "spectrometer" ) ) )
+            {
+                spectrometer_data* p_data = p_effect->p_data;
+                free( p_data->peaks );
+                free( p_data->p_prev_s16_buff );
+            }
+            free( p_effect->p_data );
         }
-        free( p_effect->p_data );
         free( p_effect->psz_args );
         free( p_effect );
 #undef p_effect
-- 
1.7.5.4




More information about the vlc-devel mailing list