visual: don't crash on empty buffers
authorTristan Matthews <le.businessman@gmail.com>
Tue, 8 Apr 2014 18:19:58 +0000 (14:19 -0400)
committerTristan Matthews <le.businessman@gmail.com>
Wed, 9 Apr 2014 15:17:56 +0000 (11:17 -0400)
Fixes #10533

modules/visualization/glspectrum.c
modules/visualization/visual/effects.c

index d3b40cc..023b0c7 100644 (file)
@@ -447,6 +447,11 @@ static void *Thread( void *p_data )
         int16_t  *p_buffs;                         /* int16_t converted buffer */
         int16_t  *p_s16_buff;                      /* int16_t converted buffer */
 
+        if (!block->i_nb_samples) {
+            msg_Err(p_filter, "no samples yet");
+            goto release;
+        }
+
         /* Allocate the buffer only if the number of samples change */
         if (block->i_nb_samples != p_sys->i_prev_nb_samples)
         {
index ca2e1bd..c043cb0 100644 (file)
@@ -119,6 +119,11 @@ static int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
     int16_t  *p_buffs;                    /* int16_t converted buffer */
     int16_t  *p_s16_buff;                 /* int16_t converted buffer */
 
+    if (!p_buffer->i_nb_samples) {
+        msg_Err(p_aout, "no samples yet");
+        return -1;
+    }
+
     /* Create p_data if needed */
     if( !p_data )
     {
@@ -451,6 +456,11 @@ static int spectrometer_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
     int16_t  *p_buffs;                    /* int16_t converted buffer */
     int16_t  *p_s16_buff;                /* int16_t converted buffer */
 
+    if (!p_buffer->i_nb_samples) {
+        msg_Err(p_aout, "no samples yet");
+        return -1;
+    }
+
     /* Create the data struct if needed */
     spectrometer_data *p_data = p_effect->p_data;
     if( !p_data )