Skip to content

Commit

Permalink
src/utils: really fix leaked groups and keys strings
Browse files Browse the repository at this point in the history
The prior approach did miss the g_auto().

Fixes 9f07e75 ("src/utils: fix leaked groups and keys strings")

Now really fixes coverity issues:
| CID 1445509 (#2 of 2): Resource leak (RESOURCE_LEAK)
| 4. leaked_storage: Variable rem_groups going out of scope leaks the storage it points to

| CID 1445498 (#2 of 2): Resource leak (RESOURCE_LEAK)
| 5. leaked_storage: Variable rem_keys going out of scope leaks the storage it points to.

Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Mar 17, 2022
1 parent 43d2f80 commit 09ec46b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ gchar *resolve_path(const gchar *basefile, gchar *path)
gboolean check_remaining_groups(GKeyFile *key_file, GError **error)
{
gsize rem_num_groups;
GStrv(rem_groups) = NULL;
g_auto(GStrv) rem_groups = NULL;

rem_groups = g_key_file_get_groups(key_file, &rem_num_groups);
if (rem_num_groups != 0) {
Expand All @@ -170,7 +170,7 @@ gboolean check_remaining_groups(GKeyFile *key_file, GError **error)
gboolean check_remaining_keys(GKeyFile *key_file, const gchar *groupname, GError **error)
{
gsize rem_num_keys;
GStrv(rem_keys) = NULL;
g_auto(GStrv) rem_keys = NULL;

rem_keys = g_key_file_get_keys(key_file, groupname, &rem_num_keys, NULL);
if (rem_keys && rem_num_keys != 0) {
Expand Down

0 comments on commit 09ec46b

Please sign in to comment.