Skip to content

Commit

Permalink
src/config_file: free groups leaking on error in load_config()
Browse files Browse the repository at this point in the history
When jumping to free: label, g_strfreev() will not be called.
Use g_autoptr() instead.

Fixes coverity issue:
| CID 1445489 (#1 of 1): Resource leak (RESOURCE_LEAK)
| 47. leaked_storage: Variable groups going out of scope leaks the storage it points to.

Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Mar 1, 2022
1 parent caa2bed commit 74fd748
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
g_autoptr(RaucConfig) c = g_new0(RaucConfig, 1);
gboolean res = FALSE;
g_autoptr(GKeyFile) key_file = NULL;
gchar **groups;
g_auto(GStrv) groups = NULL;
gsize group_count;
GList *slotlist = NULL;
GHashTable *slots = NULL;
Expand Down Expand Up @@ -741,8 +741,6 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
goto free;
}

g_strfreev(groups);

res = TRUE;
free:
if (res)
Expand Down

0 comments on commit 74fd748

Please sign in to comment.