GNOME Bugzilla – Bug 165887
g_key_file_remove_group segfaults, if group does not exist
Last modified: 2005-02-01 14:10:54 UTC
Steps to reproduce: 1. call g_key_file_remove_group on a non-existent group-id Stack trace: Other information: Already have a fix...
That's what the function should look like: void g_key_file_remove_group (GKeyFile *key_file, const gchar *group_name, GError **error) { GList *group_node; g_return_if_fail (key_file != NULL); g_return_if_fail (group_name != NULL); group_node = g_key_file_lookup_group_node (key_file, group_name); if (!group_node) g_set_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND, _("Key file does not have group '%s'"), group_name); else g_key_file_remove_group_node (key_file, group_node); }
Created attachment 36798 [details] Test-Case
Created attachment 36799 [details] [review] The fix
2005-02-01 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c (test_group_remove): Add test case for group removal. * glib/gkeyfile.c (g_key_file_remove_group): Don't segfault if the group doesn't exist. (#165887, Mathias Hasselmann)