From bb205d3d85069a8ddb4442ada1d49062837d9862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Fri, 24 Jun 2022 16:14:33 +0200 Subject: [PATCH] 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. --- spa/plugins/audioconvert/noise-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spa/plugins/audioconvert/noise-ops.c b/spa/plugins/audioconvert/noise-ops.c index c7e54ea95..1c934792e 100644 --- a/spa/plugins/audioconvert/noise-ops.c +++ b/spa/plugins/audioconvert/noise-ops.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -71,7 +72,7 @@ int noise_init(struct noise *ns) return -ENOTSUP; 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->process = info->process;