Skip to content

Commit 0d8a738

Browse files
committed
check memory allocations for failure in view.c
1 parent 1b65969 commit 0d8a738

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/views/view.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,10 +1325,15 @@ GSList *dt_mouse_action_create_simple(GSList *actions,
13251325
const char *const description)
13261326
{
13271327
dt_mouse_action_t *a = (dt_mouse_action_t *)calloc(1, sizeof(dt_mouse_action_t));
1328-
a->action = type;
1329-
a->mods = accel;
1330-
g_strlcpy(a->name, description, sizeof(a->name));
1331-
return g_slist_append(actions, a);
1328+
if(a)
1329+
{
1330+
a->action = type;
1331+
a->mods = accel;
1332+
g_strlcpy(a->name, description, sizeof(a->name));
1333+
return g_slist_append(actions, a);
1334+
}
1335+
else
1336+
return actions;
13321337
}
13331338

13341339
GSList *dt_mouse_action_create_format(GSList *actions,
@@ -1338,10 +1343,15 @@ GSList *dt_mouse_action_create_format(GSList *actions,
13381343
const char *const replacement)
13391344
{
13401345
dt_mouse_action_t *a = (dt_mouse_action_t *)calloc(1, sizeof(dt_mouse_action_t));
1341-
a->action = type;
1342-
a->mods = accel;
1343-
g_snprintf(a->name, sizeof(a->name), format_string, replacement);
1344-
return g_slist_append(actions, a);
1346+
if(a)
1347+
{
1348+
a->action = type;
1349+
a->mods = accel;
1350+
g_snprintf(a->name, sizeof(a->name), format_string, replacement);
1351+
return g_slist_append(actions, a);
1352+
}
1353+
else
1354+
return actions;
13451355
}
13461356

13471357
static gchar *_mouse_action_get_string(dt_mouse_action_t *ma)

0 commit comments

Comments
 (0)