1
0
Fork 0

Merge pull request #1932 from H3rnand3zzz/cleanup/refactor-conf-string-list

Fix mem leak in `conf_string_list_add`
This commit is contained in:
Michael Vetter 2023-11-20 11:27:20 +01:00 committed by GitHub
commit e143513f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -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;
}