From 243ff6a5111e4ff7a117b06501167cf5c37e7fb6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 29 Sep 2020 14:58:47 +0100 Subject: [PATCH] user-accounts: Fix a critical warning if loading a cursor fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s possible for `gdk_cursor_new_for_display()` to return `NULL`. It’s OK to pass `NULL` to `gdk_window_set_cursor()`, but not OK to then unref it. Signed-off-by: Philip Withnall --- panels/user-accounts/cc-crop-area.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panels/user-accounts/cc-crop-area.c b/panels/user-accounts/cc-crop-area.c index c4a04a630..fc7cb621d 100644 --- a/panels/user-accounts/cc-crop-area.c +++ b/panels/user-accounts/cc-crop-area.c @@ -352,10 +352,10 @@ update_cursor (CcCropArea *area, } if (cursor_type != area->current_cursor) { - GdkCursor *cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (area)), - cursor_type); + g_autoptr(GdkCursor) cursor = NULL; + cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (area)), + cursor_type); gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (area)), cursor); - g_object_unref (cursor); area->current_cursor = cursor_type; } }