From 8e44f1e0b6662e6c805945dcfcd3acbff5f0ba69 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 18 Apr 2025 09:40:51 -0300 Subject: [PATCH] locale: Fix UB in elem_hash The ubsan triggers: UBSAN: Undefined behaviour in ./elem-hash.h:27:14 left shift of 360447856 by 3 cannot be represented in type 'int' Using unsigned shift here zero fill like signed. --- locale/elem-hash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/elem-hash.h b/locale/elem-hash.h index 5d34ec43f3..8052b0fe6d 100644 --- a/locale/elem-hash.h +++ b/locale/elem-hash.h @@ -24,7 +24,7 @@ elem_hash (const char *str, int32_t n) while (n-- > 0) { - result <<= 3; + result = (uint32_t)result << 3; result += *str++; } -- 2.47.2