]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: Handle upper bound in peak calculations
authorTakashi Iwai <tiwai@suse.de>
Tue, 24 Aug 2021 08:00:26 +0000 (10:00 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 24 Aug 2021 08:00:26 +0000 (10:00 +0200)
Make sure that the calculated max_peak[] won't go beyond the sample
max resolution.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
aplay/aplay.c

index 2543de5b6cd842403523be57078350e5f660ddac..a51a37ba34bd18fbdae0fff9e9ccfcc679932859 100644 (file)
@@ -1898,6 +1898,8 @@ static void compute_max_peak(u_char *data, size_t samples)
                max = 0x7fffffff;
 
        for (c = 0; c < ichans; c++) {
+               if (max_peak[c] > max)
+                       max_peak[c] = max;
                if (bits_per_sample > 16)
                        perc[c] = max_peak[c] / (max / 100);
                else