From 6c07635ebcaa26ed852aea664c88c4fef3ea710e Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 19 Oct 2023 10:25:12 -0400 Subject: [PATCH] Fix undefined behaviour in volk_32u_reverse_32u Signed-off-by: Clayton Smith --- kernels/volk/volk_32u_reverse_32u.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernels/volk/volk_32u_reverse_32u.h b/kernels/volk/volk_32u_reverse_32u.h index f65ec6098..981d4672f 100644 --- a/kernels/volk/volk_32u_reverse_32u.h +++ b/kernels/volk/volk_32u_reverse_32u.h @@ -206,7 +206,7 @@ volk_32u_reverse_32u_lut(uint32_t* out, const uint32_t* in, unsigned int num_poi uint32_t* out_ptr = out; unsigned int number = 0; for (; number < num_points; ++number) { - *out_ptr = (BitReverseTable256[*in_ptr & 0xff] << 24) | + *out_ptr = ((uint32_t)BitReverseTable256[*in_ptr & 0xff] << 24) | (BitReverseTable256[(*in_ptr >> 8) & 0xff] << 16) | (BitReverseTable256[(*in_ptr >> 16) & 0xff] << 8) | (BitReverseTable256[(*in_ptr >> 24) & 0xff]); @@ -354,7 +354,7 @@ volk_32u_reverse_32u_neonv8(uint32_t* out, const uint32_t* in, unsigned int num_ } number = quarterPoints * 4; for (; number < num_points; ++number) { - *out_ptr = (BitReverseTable256[*in_ptr & 0xff] << 24) | + *out_ptr = ((uint32_t)BitReverseTable256[*in_ptr & 0xff] << 24) | (BitReverseTable256[(*in_ptr >> 8) & 0xff] << 16) | (BitReverseTable256[(*in_ptr >> 16) & 0xff] << 8) | (BitReverseTable256[(*in_ptr >> 24) & 0xff]);