[gimp/gimp-2-8] app: gimp_procedure_execute(): don't use a NULL plug-ins error message



commit a833a30c2cbcac22559ad9646ef06a555bc2ec7e
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 14 17:28:42 2014 +0100

    app: gimp_procedure_execute(): don't use a NULL plug-ins error message
    
    return_vals[1] being present and being a string doesn't neccessarily
    mean it comes from the plug-in, it might just as well be its first
    return value, which gets generated and NULL-initialized by the plug-in
    execution code even if the plug-in didn't actually return anything.
    
    (cherry picked from commit 60014630fa732365e03683bb31ac6a2b2511fe79)

 app/pdb/gimpprocedure.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index 7c1b726..96f1dff 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -347,15 +347,17 @@ gimp_procedure_execute (GimpProcedure  *procedure,
            *  from the error message that is optionally passed with
            *  the return values.
            */
-          if (error && *error == NULL)
+          if (error && *error == NULL &&
+              return_vals->n_values > 1 &&
+              G_VALUE_HOLDS_STRING (&return_vals->values[1]))
             {
-              if (return_vals->n_values > 1 &&
-                  G_VALUE_HOLDS_STRING (&return_vals->values[1]))
-                {
-                  g_set_error_literal (error, GIMP_PDB_ERROR,
-                                       GIMP_PDB_ERROR_FAILED,
-                                      g_value_get_string (&return_vals->values[1]));
-                }
+              GValue      *value   = &return_vals->values[1];
+              const gchar *message = g_value_get_string (value);
+
+              if (message)
+                g_set_error_literal (error, GIMP_PDB_ERROR,
+                                     GIMP_PDB_ERROR_FAILED,
+                                     message);
             }
           break;
 


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