From 0dd5937707990daa38e17ab5da168ddf557d0939 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 29 Nov 2019 21:24:41 +0100 Subject: [PATCH] Player: Prevent overflows in vol_up() and vol_down(). --- src/player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 2a9f337..5635fe8 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -464,14 +464,14 @@ void Player::set_volume(uint8_t vol, bool save) { void Player::vol_up() { if (!is_playing()) return; - uint8_t vol = _volume + VOLUME_STEP; + uint16_t vol = _volume + VOLUME_STEP; if (vol > VOLUME_MAX) vol=VOLUME_MAX; set_volume(vol); } void Player::vol_down() { if (!is_playing()) return; - uint8_t vol = _volume - VOLUME_STEP; + int16_t vol = _volume - VOLUME_STEP; if (vol < VOLUME_MIN) vol=VOLUME_MIN; set_volume(vol); }