1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-09 21:30:42 +00:00

Fix mem leak in conf_string_list_add

Introduced in 1cf7973245
Issue reported and fix proposed by @sjaeckel
This commit is contained in:
John Hernandez 2023-11-14 16:27:04 +01:00
parent 08d2a51ae4
commit bd2821fafa
No known key found for this signature in database
GPG Key ID: 00B2D64859378A94

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 // 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) { 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; 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; return TRUE;
} }