Skip to content

Commit 103a719

Browse files
committed
check memory allocations for failure in tagging module
1 parent a4ff173 commit 103a719

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/libs/tagging.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,16 +1969,21 @@ static void _pop_menu_dictionary_edit_tag(GtkWidget *menuitem, dt_lib_module_t *
19691969
// update the store
19701970
GtkTreeModel *store = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
19711971
dt_tag_op_t *to = g_malloc(sizeof(dt_tag_op_t));
1972-
to->tree_flag = d->tree_flag;
1973-
to->oldtagname = tagname;
1974-
to->newtagname = new_prefix_tag;
1975-
gint sort_column;
1976-
GtkSortType sort_order;
1977-
gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(store), &sort_column, &sort_order);
1978-
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
1979-
gtk_tree_model_foreach(store, (GtkTreeModelForeachFunc)_update_tag_name_per_name, to);
1980-
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), sort_column, sort_order);
1981-
g_free(to);
1972+
if(to)
1973+
{
1974+
to->tree_flag = d->tree_flag;
1975+
to->oldtagname = tagname;
1976+
to->newtagname = new_prefix_tag;
1977+
gint sort_column;
1978+
GtkSortType sort_order;
1979+
gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(store), &sort_column, &sort_order);
1980+
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
1981+
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
1982+
GTK_SORT_ASCENDING);
1983+
gtk_tree_model_foreach(store, (GtkTreeModelForeachFunc)_update_tag_name_per_name, to);
1984+
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), sort_column, sort_order);
1985+
g_free(to);
1986+
}
19821987
if(subtag) g_free(new_prefix_tag);
19831988

19841989
_raise_signal_tag_changed(self);
@@ -2342,9 +2347,12 @@ static void _pop_menu_dictionary(GtkWidget *treeview, GdkEventButton *event, dt_
23422347
if(d->collection[0])
23432348
{
23442349
char *collection = g_malloc(4096);
2345-
dt_collection_serialize(collection, 4096, FALSE);
2346-
if(g_strcmp0(d->collection, collection) == 0) d->collection[0] = '\0';
2347-
g_free(collection);
2350+
if(collection)
2351+
{
2352+
dt_collection_serialize(collection, 4096, FALSE);
2353+
if(g_strcmp0(d->collection, collection) == 0) d->collection[0] = '\0';
2354+
g_free(collection);
2355+
}
23482356
}
23492357
if(count || d->collection[0])
23502358
{

0 commit comments

Comments
 (0)