[vlc-devel] commit: Audio output: fix integer overflow ( Jean-Philippe André )

git version control git at videolan.org
Sun Jan 17 16:57:31 CET 2010


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Sun Jan 17 16:35:10 2010 +0100| [96e872ee848edad188d0b94d7df085fceeadd7ce] | committer: Jean-Philippe André 

Audio output: fix integer overflow

This fixes the following bug:
When scrolling the mouse wheel down, volume jumps from 0% to 400%.

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

 src/audio_output/intf.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c
index db55c4a..b924904 100644
--- a/src/audio_output/intf.c
+++ b/src/audio_output/intf.c
@@ -76,7 +76,7 @@ int doVolumeChanges( unsigned action, vlc_object_t * p_object, int i_nb_steps,
                 bool b_mute )
 {
     int i_result = VLC_SUCCESS;
-    int i_volume_step = 1;
+    int i_volume_step = 1, i_new_volume = 0;
     bool b_var_mute = false;
     aout_instance_t *p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
                                                FIND_ANYWHERE );
@@ -120,12 +120,16 @@ int doVolumeChanges( unsigned action, vlc_object_t * p_object, int i_nb_steps,
 
         if ( !b_unmute_condition )
             i_volume = config_GetInt( p_object, "volume" );
-        i_volume += i_volume_step * i_nb_steps;
 
-        if ( i_volume > AOUT_VOLUME_MAX )
+        i_new_volume = (int) i_volume + i_volume_step * i_nb_steps;
+
+        if ( i_new_volume > AOUT_VOLUME_MAX )
             i_volume = AOUT_VOLUME_MAX;
-        else if ( i_volume < AOUT_VOLUME_MIN )
+        else if ( i_new_volume < AOUT_VOLUME_MIN )
             i_volume = AOUT_VOLUME_MIN;
+        else
+            i_volume = i_new_volume;
+
         if ( i_return_volume != NULL )
             *i_return_volume = i_volume;
     }




More information about the vlc-devel mailing list