spa: audioconvert: use unsigned 64-bit integer for creating divisor

Using `int` results in UndefinedBehaviorSanitizer errors
when `noise::intensity` is 31 as that would shift the 1 into
the sign bit of a signed integer type.
This commit is contained in:
Barnabás Pőcze 2022-06-24 16:14:33 +02:00
parent 43f7831d14
commit bb205d3d85

View file

@ -24,6 +24,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <math.h> #include <math.h>
#include <spa/param/audio/format-utils.h> #include <spa/param/audio/format-utils.h>
@ -71,7 +72,7 @@ int noise_init(struct noise *ns)
return -ENOTSUP; return -ENOTSUP;
for (i = 0; i < SPA_N_ELEMENTS(ns->tab); i++) for (i = 0; i < SPA_N_ELEMENTS(ns->tab); i++)
ns->tab[i] = (drand48() - 0.5) / (1 << ns->intensity); ns->tab[i] = (drand48() - 0.5) / (UINT64_C(1) << ns->intensity);
ns->free = impl_noise_free; ns->free = impl_noise_free;
ns->process = info->process; ns->process = info->process;