From bc524d4e17e87ebff28efb31e16e83f4edfcdd19 Mon Sep 17 00:00:00 2001 From: appositeit Date: Sat, 21 Mar 2026 01:17:53 +1100 Subject: [PATCH] fix: NULL check in meta_x11_display_logical_monitor_to_xinerama_index Add a NULL check for logical_monitor_data before dereferencing it. When Xinerama screen geometry doesn't exactly match any logical monitor's rect (common with NVIDIA multi-monitor setups after sleep/wake or monitor power cycles), ensure_xinerama_indices() never attaches qdata to that monitor. The subsequent call to get_x11_display_logical_monitor_data() then returns NULL, and dereferencing it causes a segfault at offset +94 in meta_display_logical_index_to_xinerama_index. This crash is reproducible on NVIDIA GPUs with 2+ monitors and triggers when monitors power off/on or wake from sleep. It causes Cinnamon to enter fallback mode and often requires a GDM restart to recover. The sibling function meta_x11_display_xinerama_index_to_logical_monitor already handles the NULL case correctly (returns NULL when no match). Fixes: #671 Co-Authored-By: Claude Opus 4.6 --- src/x11/meta-x11-display.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c index 2af3b39de..280541d88 100644 --- a/src/x11/meta-x11-display.c +++ b/src/x11/meta-x11-display.c @@ -2090,6 +2090,9 @@ meta_x11_display_logical_monitor_to_xinerama_index (MetaX11Display *x11_disp logical_monitor_data = get_x11_display_logical_monitor_data (logical_monitor); + if (logical_monitor_data == NULL) + return -1; + return logical_monitor_data->xinerama_index; }