gtkcssnodedeclaration: Avoid signed left shift by 31 bits

Left-shifting a signed 32-bit integer by 31 bits (such that the value
overflows into the sign bit) is undefined behaviour. Use an unsigned
integer instead.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie
2024-07-27 19:08:22 +01:00
parent 6649af5ec6
commit b769295682

View File

@@ -446,9 +446,9 @@ gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
for (i = 0; i < sizeof (GtkStateFlags) * 8; i++)
{
if (decl->state & (1 << i))
if (decl->state & (1u << i))
{
const char *name = gtk_css_pseudoclass_name (1 << i);
const char *name = gtk_css_pseudoclass_name (1u << i);
g_assert (name);
g_string_append_c (string, ':');
g_string_append (string, name);