Fix enum boundaries we check in func_selection_changed (when
authorwwp <wwp@free.fr>
Tue, 27 Dec 2016 17:02:55 +0000 (18:02 +0100)
committerwwp <wwp@free.fr>
Tue, 27 Dec 2016 17:02:55 +0000 (18:02 +0100)
changing the internal function assigned to a toolbar item).
Just a theoretical issue here apparently, or we would have had
problems since ages.

src/prefs_toolbar.c

index 24efd931fb035a8f24c61728f9f54737f91296fe..b86835b58e45d4aa3da6274d7527f47a95fb4085 100644 (file)
@@ -861,15 +861,18 @@ static void func_selection_changed(GtkComboBox *action_combo,
                           prefs_toolbar->item_func_combo));
 
        if(text != NULL) { /* action */
-               int action = -1;
+               int action;
+
                action = toolbar_ret_val_from_descr(text);
-               if (action >= 0)
+               g_free(text);
+               if (action > -1) {
+                       gint icon;
+
                        gtk_entry_set_text(GTK_ENTRY(prefs_toolbar->item_text_entry),
                                        toolbar_get_short_text(action));
-               g_free(text);
-               if (action >= 0) {
-                       StockPixmap stockp = toolbar_get_icon(action);
-                       if (stockp >= 0)  {
+                       icon = toolbar_get_icon(action);
+                       if (icon > -1)  {
+                               StockPixmap stockp = (StockPixmap)icon;
                                g_free(prefs_toolbar->item_icon_file);
                                prefs_toolbar->item_icon_file = g_strdup(stock_pixmap_get_name(stockp));