From 29a243e3d78f13e94e25517bf95323c3537a118c Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Tue, 26 Sep 2023 18:47:01 -0500 Subject: [PATCH] printoperation: fix case where operation may complete multiple twice If we are the final backend, then after removing ourselves there is no backend remaining. We will schedule the idle even if it has already been scheduled. This idle is required to run exactly once and executing it twices results in a double free that crashes loupe when printing. It also causes the user callback to execute twice, which could cause similar problems. Fixes #6122 --- gtk/print/gtkprintoperation-unix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk/print/gtkprintoperation-unix.c b/gtk/print/gtkprintoperation-unix.c index db4d878e33..7a6fb04254 100644 --- a/gtk/print/gtkprintoperation-unix.c +++ b/gtk/print/gtkprintoperation-unix.c @@ -1135,7 +1135,10 @@ printer_list_done_cb (GtkPrintBackend *backend, gtk_print_backend_destroy (backend); g_object_unref (backend); - if (finder->backends == NULL) + /* If there are no more backends left after removing ourselves from the list + * above, then we're finished. + */ + if (finder->backends == NULL && !finder->found_printer) g_idle_add (find_printer_idle, finder); } -- 2.30.2