mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-08 17:55:42 +01:00
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:
parent
5c4bf63a94
commit
d9b3133815
1 changed files with 4 additions and 1 deletions
|
@ -1874,7 +1874,10 @@ static void compute_max_peak(u_char *data, size_t samples)
|
||||||
else
|
else
|
||||||
val = be32toh(*valp);
|
val = be32toh(*valp);
|
||||||
val ^= mask;
|
val ^= mask;
|
||||||
val = abs(val);
|
if (val == 0x80000000U)
|
||||||
|
val = 0x7fffffff;
|
||||||
|
else
|
||||||
|
val = abs(val);
|
||||||
if (max_peak[c] < val)
|
if (max_peak[c] < val)
|
||||||
max_peak[c] = val;
|
max_peak[c] = val;
|
||||||
valp++;
|
valp++;
|
||||||
|
|
Loading…
Reference in a new issue