[vlc-commits] visual: don't crash on empty buffers

Tristan Matthews git at videolan.org
Wed Apr 9 17:18:47 CEST 2014


vlc | branch: master | Tristan Matthews <le.businessman at gmail.com> | Tue Apr  8 14:19:58 2014 -0400| [6c4493a71679f3995b81c828511a65896b6af88d] | committer: Tristan Matthews

visual: don't crash on empty buffers

Fixes #10533

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6c4493a71679f3995b81c828511a65896b6af88d
---

 modules/visualization/glspectrum.c     |    5 +++++
 modules/visualization/visual/effects.c |   10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/modules/visualization/glspectrum.c b/modules/visualization/glspectrum.c
index d3b40cc..023b0c7 100644
--- a/modules/visualization/glspectrum.c
+++ b/modules/visualization/glspectrum.c
@@ -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)
         {
diff --git a/modules/visualization/visual/effects.c b/modules/visualization/visual/effects.c
index ca2e1bd..c043cb0 100644
--- a/modules/visualization/visual/effects.c
+++ b/modules/visualization/visual/effects.c
@@ -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 )



More information about the vlc-commits mailing list