After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 165887 - g_key_file_remove_group segfaults, if group does not exist
g_key_file_remove_group segfaults, if group does not exist
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.6.x
Other All
: High critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-02-01 03:33 UTC by Mathias Hasselmann (IRC: tbf)
Modified: 2005-02-01 14:10 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Test-Case (451 bytes, text/x-csrc)
2005-02-01 03:35 UTC, Mathias Hasselmann (IRC: tbf)
  Details
The fix (390 bytes, patch)
2005-02-01 03:35 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review

Description Mathias Hasselmann (IRC: tbf) 2005-02-01 03:33:42 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...
Comment 1 Mathias Hasselmann (IRC: tbf) 2005-02-01 03:34:36 UTC
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);

}
Comment 2 Mathias Hasselmann (IRC: tbf) 2005-02-01 03:35:13 UTC
Created attachment 36798 [details]
Test-Case
Comment 3 Mathias Hasselmann (IRC: tbf) 2005-02-01 03:35:56 UTC
Created attachment 36799 [details] [review]
The fix
Comment 4 Matthias Clasen 2005-02-01 14:10:54 UTC
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)