Skip to content

Commit

Permalink
Fix mem leak in conf_string_list_add
Browse files Browse the repository at this point in the history
Introduced in 1cf7973
Issue reported and fix proposed by @sjaeckel
  • Loading branch information
H3rnand3zzz committed Nov 17, 2023
1 parent 08d2a51 commit bd2821f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/config/conflists.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ conf_string_list_add(GKeyFile* keyfile, const char* const group, const char* con
}

// Add item to the existing list
gchar** new_list = g_new(gchar*, length + 2);
const gchar** new_list = g_new(const gchar*, length + 2);
for (gsize i = 0; i < length; ++i) {
new_list[i] = g_strdup(list[i]);
new_list[i] = list[i];
}
new_list[length] = g_strdup(item);
new_list[length] = item;
new_list[length + 1] = NULL;

g_key_file_set_string_list(keyfile, group, key, (const gchar* const*)new_list, length + 1);
g_key_file_set_string_list(keyfile, group, key, new_list, length + 1);

g_free(new_list);

return TRUE;
}
Expand Down

0 comments on commit bd2821f

Please sign in to comment.