From 379996a63eabdc49f31ee529e1db21411b3bdc80 Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Wed, 30 Aug 2023 15:43:43 -0400 Subject: [PATCH] onscreen/native: Check frame_info for null in finish frame callback While adjusting the monitor layout of my docked laptop, mutter got a segfault while attempting to dereference the frame_info struct. This happened on gnome-shell 44.4-1.fc38. cogl_onscreen_peek_head_frame_info() just forwards the call to g_queue_peek_head() which returns NULL in the event that the queue is empty. If finish_frame_result_feedback() is expected to always be called with a non-empty queue there's still a bug somewhere, but regardless this API can legitimately return NULL so it should be checked for prior to dereferencing. Fixes: 61801a713a29 ("onscreen/native: Avoid freezing the frame clock on failed cursor commits") Part-of: --- src/backends/native/meta-onscreen-native.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index a3ba44711..2388a44a2 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1530,6 +1530,12 @@ finish_frame_result_feedback (const MetaKmsFeedback *kms_feedback, g_warning ("Cursor update failed: %s", error->message); frame_info = cogl_onscreen_peek_head_frame_info (onscreen); + if (!frame_info) + { + g_warning ("The feedback callback was called, but there was no frame info"); + return; + } + frame_info->flags |= COGL_FRAME_INFO_FLAG_SYMBOLIC; meta_onscreen_native_notify_frame_complete (onscreen);