]> git.sesse.net Git - vlc/commitdiff
Prevent setting volume to outrageous values.
authorAntoine Cellerier <dionoea@videolan.org>
Mon, 21 Dec 2009 22:12:32 +0000 (23:12 +0100)
committerAntoine Cellerier <dionoea@videolan.org>
Mon, 21 Dec 2009 22:12:32 +0000 (23:12 +0100)
modules/misc/lua/libs/volume.c

index 23a0d5c84092d0e2e6ec5d274371c1f725dd3b07..12a290f77072e60774f00c09dd2960e8c98d1222 100644 (file)
@@ -53,8 +53,8 @@
 static int vlclua_volume_set( lua_State *L )
 {
     playlist_t *p_this = vlclua_get_playlist_internal( L );
-    int i_volume = luaL_checkint( L, 1 );
-    /* Do we need to check that i_volume is in the AOUT_VOLUME_MIN->MAX range?*/
+    int i_volume = __MAX(__MIN(luaL_checkint( L, 1 ), AOUT_VOLUME_MAX),
+                         AOUT_VOLUME_MIN);
     int i_ret = aout_VolumeSet( p_this, i_volume );
     vlclua_release_playlist_internal( p_this );
     return vlclua_push_ret( L, i_ret );