Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mem leak in conf_string_list_add #1932

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading