[gimp/gimp-2-10] app: fix potential segfault in gimp_action_history_activate_callback()



commit 9f0f11f44e47090ea47858d2a1bf26de38e74fc6
Author: Ell <ell_se yahoo com>
Date:   Thu Jul 5 13:27:02 2018 -0400

    app: fix potential segfault in gimp_action_history_activate_callback()
    
    In gimp_action_history_activate_callback(), bail if history.gimp is
    NULL, instead of dereferencing it.  This can happen if GIMP is shut
    down during the execution of a temporary procedure, such as a
    script-fu script.  See the code comment for details.
    
    (cherry picked from commit 6544ce4301fa43636b4c282c7b4815e18fd653d1)

 app/widgets/gimpaction-history.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/app/widgets/gimpaction-history.c b/app/widgets/gimpaction-history.c
index 675966a34d..e94aedc8a6 100644
--- a/app/widgets/gimpaction-history.c
+++ b/app/widgets/gimpaction-history.c
@@ -355,11 +355,25 @@ void
 gimp_action_history_activate_callback (GtkAction *action,
                                        gpointer   user_data)
 {
-  GimpGuiConfig         *config = GIMP_GUI_CONFIG (history.gimp->config);
+  GimpGuiConfig         *config;
   const gchar           *action_name;
   GList                 *link;
   GimpActionHistoryItem *item;
 
+  /* we can get here after gimp_action_history_exit() has been called, if
+   * gimp_exit() was called during the execution of a temporary procedure,
+   * which was executed in response to a GimpProcedureAction, such as a script-
+   * fu script (temporary procedures run a nested mainloop, during which
+   * anything can happen.)  the GimpProcedureAction's "selected" signal, in
+   * response to which the procedure is run, is emitted before any user-
+   * provided "activate" handlers are invoked, and so this function will be
+   * called *after* the procedure returns.
+   */
+  if (! history.gimp)
+    return;
+
+  config = GIMP_GUI_CONFIG (history.gimp->config);
+
   if (config->action_history_size == 0)
     return;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]