From: Takashi Iwai Date: Tue, 24 Aug 2021 07:58:29 +0000 (+0200) Subject: aplay: Don't pass most negative integer to abs() in peak calculations X-Git-Tag: v1.2.6~22 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=d9b31338153591944d72e62523bad7850b407c63;p=alsa-utils.git aplay: Don't pass most negative integer to abs() in peak calculations The return value from abs() for the most negative integer is undefined. Cap it properly for the 32bit sample handling. Signed-off-by: Takashi Iwai --- diff --git a/aplay/aplay.c b/aplay/aplay.c index c884346..2543de5 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -1874,7 +1874,10 @@ static void compute_max_peak(u_char *data, size_t samples) else val = be32toh(*valp); val ^= mask; - val = abs(val); + if (val == 0x80000000U) + val = 0x7fffffff; + else + val = abs(val); if (max_peak[c] < val) max_peak[c] = val; valp++;