From af18a0c4c9bab4178c04dffb8edd2cc5cba6b47a Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 14 Oct 2021 01:46:02 +0300 Subject: [PATCH] screen-share: Avoid bit-shifting large values Found while running with b_sanitize=undefined, which yields: runtime error: shift exponent 909199186 is too large for 32-bit type 'int' Converts the shm_formats to a boolean and checks for the correct pixel format it directly, instead of trying to gather them all in an array and then later on to do the check. Signed-off-by: Marius Vlad --- compositor/screen-share.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compositor/screen-share.c b/compositor/screen-share.c index 60f25556..b820278f 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -60,7 +60,7 @@ struct shared_output { struct wl_registry *registry; struct wl_compositor *compositor; struct wl_shm *shm; - uint32_t shm_formats; + bool shm_formats_has_xrgb; struct zwp_fullscreen_shell_v1 *fshell; struct wl_output *output; struct wl_surface *surface; @@ -701,7 +701,8 @@ shm_handle_format(void *data, struct wl_shm *wl_shm, uint32_t format) { struct shared_output *so = data; - so->parent.shm_formats |= (1 << format); + if (format == WL_SHM_FORMAT_XRGB8888) + so->parent.shm_formats_has_xrgb = true; } struct wl_shm_listener shm_listener = { @@ -967,7 +968,7 @@ shared_output_create(struct weston_output *output, int parent_fd) /* Get SHM formats */ wl_display_roundtrip(so->parent.display); - if (!(so->parent.shm_formats & (1 << WL_SHM_FORMAT_XRGB8888))) { + if (!so->parent.shm_formats_has_xrgb) { weston_log("Screen share failed: " "WL_SHM_FORMAT_XRGB8888 not available\n"); goto err_display;