From 6e0f760117c3b4417b98a3c2431c36d8909fbc06 Mon Sep 17 00:00:00 2001 From: bandithedoge Date: Mon, 13 Jan 2025 13:17:56 +0100 Subject: [PATCH] cairo-xcb-connection.c: fix undefined behavior in DEPTH_MASK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bit-shifting a signed integer (which is what 1 is here) left is undefined behavior – you can see it when compiling with `-fsanitize=undefined`. Explicitly declaring 1 as unsigned fixes this. --- src/cairo-xcb-connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c index 213c920ac..016ca1c0c 100644 --- a/src/cairo-xcb-connection.c +++ b/src/cairo-xcb-connection.c @@ -239,7 +239,7 @@ _cairo_xcb_connection_parse_xrender_formats (cairo_xcb_connection_t *connection, /* * We require support for depth 1, 8, 24 and 32 pixmaps */ -#define DEPTH_MASK(d) (1 << ((d) - 1)) +#define DEPTH_MASK(d) ((uint32_t)(1) << ((d) - 1)) #define REQUIRED_DEPTHS (DEPTH_MASK(1) | \ DEPTH_MASK(8) | \ DEPTH_MASK(24) | \