From 7cd807893677a45806fdd106694b2efca8f750b8 Mon Sep 17 00:00:00 2001 From: Felipe Borges Date: Mon, 9 Apr 2018 11:42:35 +0200 Subject: printers: Fix crash when panel is closed quickly Fix a user-after-free while testing the connectivity to a cups server. This is similar to the fix in commit 1d72a0b. This is an addition to the changes introduced in commit 2ff5cfd which allowed the connection testing to be cancellable. Fixes #51 Fixes https://bugzilla.gnome.org/794632 --- panels/printers/cc-printers-panel.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c index 4815c4520..b9b2ca82b 100644 --- a/panels/printers/cc-printers-panel.c +++ b/panels/printers/cc-printers-panel.c @@ -1230,13 +1230,11 @@ connection_test_cb (GObject *source_object, gpointer user_data) { CcPrintersPanelPrivate *priv; - CcPrintersPanel *self = (CcPrintersPanel*) user_data; + CcPrintersPanel *self; gboolean success; PpCups *cups = PP_CUPS (source_object); g_autoptr(GError) error = NULL; - priv = self->priv; - success = pp_cups_connection_test_finish (cups, result, &error); if (error != NULL) @@ -1244,9 +1242,14 @@ connection_test_cb (GObject *source_object, if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warning ("Could not test connection: %s", error->message); + + return; } } + self = CC_PRINTERS_PANEL (user_data); + priv = self->priv; + if (!success) { priv->cups_status_check_id = -- cgit v1.2.1