diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 8 | ||||
-rw-r--r-- | glib/gkeyfile.c | 4 | ||||
-rw-r--r-- | tests/keyfile-test.c | 70 |
6 files changed, 104 insertions, 2 deletions
@@ -1,3 +1,11 @@ +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) + 2005-01-30 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c: Some more unit tests. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index bbf150155..a93dd1b23 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +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) + 2005-01-30 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c: Some more unit tests. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index bbf150155..a93dd1b23 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +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) + 2005-01-30 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c: Some more unit tests. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index bbf150155..a93dd1b23 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +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) + 2005-01-30 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c: Some more unit tests. diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index a2e428936..b68efbdbd 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c @@ -2768,8 +2768,8 @@ g_key_file_remove_group (GKeyFile *key_file, G_KEY_FILE_ERROR_GROUP_NOT_FOUND, _("Key file does not have group '%s'"), group_name); - - g_key_file_remove_group_node (key_file, group_node); + else + g_key_file_remove_group_node (key_file, group_node); } static void diff --git a/tests/keyfile-test.c b/tests/keyfile-test.c index 0e86af992..62e4e2243 100644 --- a/tests/keyfile-test.c +++ b/tests/keyfile-test.c @@ -519,6 +519,8 @@ test_boolean (void) g_key_file_get_boolean (keyfile, "invalid", "key4", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); + + g_key_file_free (keyfile); } /* check parsing of integer values */ @@ -562,6 +564,73 @@ test_integer (void) g_key_file_get_integer (keyfile, "invalid", "key4", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); + + g_key_file_free (keyfile); +} + +/* http://bugzilla.gnome.org/show_bug.cgi?id=165887 */ +static void +test_group_remove (void) +{ + GKeyFile *keyfile; + gchar **names; + gsize len; + GError *error = NULL; + + const gchar *data = + "[group1]\n" + "[group2]\n" + "key1=bla\n" + "key2=bla\n" + "[group3]\n" + "key1=bla\n" + "key2=bla\n"; + + keyfile = load_data (data, 0); + + names = g_key_file_get_groups (keyfile, &len); + if (names == NULL) + { + g_print ("Error listing groups\n"); + exit (1); + } + + check_length ("groups", g_strv_length (names), len, 3); + check_name ("group name", names[0], "group1", 0); + check_name ("group name", names[1], "group2", 1); + check_name ("group name", names[2], "group3", 2); + + g_key_file_remove_group (keyfile, "group1", &error); + check_no_error (&error); + + names = g_key_file_get_groups (keyfile, &len); + if (names == NULL) + { + g_print ("Error listing groups\n"); + exit (1); + } + + check_length ("groups", g_strv_length (names), len, 2); + check_name ("group name", names[0], "group2", 0); + check_name ("group name", names[1], "group3", 1); + + g_key_file_remove_group (keyfile, "group2", &error); + check_no_error (&error); + + names = g_key_file_get_groups (keyfile, &len); + if (names == NULL) + { + g_print ("Error listing groups\n"); + exit (1); + } + + check_length ("groups", g_strv_length (names), len, 1); + check_name ("group name", names[0], "group3", 0); + + g_key_file_remove_group (keyfile, "no such group", &error); + check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND); + + g_key_file_free (keyfile); } /* check handling of translated strings */ @@ -680,6 +749,7 @@ main (int argc, char *argv[]) test_integer (); test_locale_string (); test_lists (); + test_group_remove (); return 0; } |