[gimp] libgimpwidgets: handle invalid enum values in gimp_enum_store_set_icon_prefix()



commit 3c2b4df6e624e7bd3a2ded5f5a3aa0cff529b09f
Author: Ell <ell_se yahoo com>
Date:   Wed Dec 28 19:51:16 2016 -0500

    libgimpwidgets: handle invalid enum values in gimp_enum_store_set_icon_prefix()
    
    If the store has invalid enum values the function segfaults,
    instead of just ignoring them.  We use -1 to represent separator
    rows in the layer mode combo; if we end up adding icons to this
    combo, we need it... not to segfault.  Since this is public API,
    it should probably be prepared to handle such uses regardless.

 libgimpwidgets/gimpenumstore.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/libgimpwidgets/gimpenumstore.c b/libgimpwidgets/gimpenumstore.c
index 5187bff..3f5e359 100644
--- a/libgimpwidgets/gimpenumstore.c
+++ b/libgimpwidgets/gimpenumstore.c
@@ -375,9 +375,12 @@ gimp_enum_store_set_icon_prefix (GimpEnumStore *store,
 
           enum_value = g_enum_get_value (store->enum_class, value);
 
-          icon_name = g_strconcat (icon_prefix, "-",
-                                   enum_value->value_nick,
-                                   NULL);
+          if (enum_value)
+            {
+              icon_name = g_strconcat (icon_prefix, "-",
+                                       enum_value->value_nick,
+                                       NULL);
+            }
         }
 
       gtk_list_store_set (GTK_LIST_STORE (store), &iter,


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