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 <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2021-08-24 09:58:29 +02:00
parent 5c4bf63a94
commit d9b3133815

View file

@ -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++;