From: Michael Catanzaro Date: Tue, 26 Sep 2023 23:47:01 +0000 (-0500) Subject: printoperation: fix case where operation may complete multiple twice X-Git-Tag: archive/raspbian/4.12.4+ds-3+rpi1^2~21^2~1^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=29a243e3d78f13e94e25517bf95323c3537a118c;p=gtk4.git 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 --- 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); }