[scaffold] don't crash on exit
- From: aurelien naldi <aurelien resus univ-mrs fr>
- To: Gnome Devtools list <gnome-devtools gnome org>
- Subject: [scaffold] don't crash on exit
- Date: Sun, 21 Dec 2003 12:42:03 +0100
hello,
the attached patch prevents scaffold from crashing on exit and remove an
unused variable.
a xmlDoc was freed too early and its memory reused.
happy hollidays to all :)
--
aurelien
Index: scaffold-session.c
===================================================================
RCS file: /cvs/gnome/scaffold/libscaffold/scaffold-session.c,v
retrieving revision 1.3
diff -u -r1.3 scaffold-session.c
--- scaffold-session.c 8 Aug 2003 20:44:19 -0000 1.3
+++ scaffold-session.c 21 Dec 2003 11:35:56 -0000
@@ -39,6 +39,7 @@
char *name;
GHashTable *properties;
GHashTable *groups;
+ xmlDocPtr doc;
};
static void dispose (GObject *object);
@@ -103,6 +104,7 @@
g_free (session->priv->name);
g_hash_table_destroy (session->priv->properties);
g_hash_table_destroy (session->priv->groups);
+ xmlFreeDoc(session->priv->doc);
g_free (session->priv);
session->priv = NULL;
}
@@ -236,7 +238,8 @@
parse_node (session, node);
}
- xmlFreeDoc (doc);
+ /* doc shouldn't be freed here but only after the last node is freed */
+ session->priv->doc = doc;
}
static void
@@ -412,8 +415,6 @@
scaffold_session_set_group (ScaffoldSession *session,
xmlNodePtr group)
{
- xmlChar *name;
-
g_return_if_fail (SCAFFOLD_IS_SESSION (session));
g_return_if_fail (group != NULL);
@@ -423,11 +424,7 @@
return;
}
- /* Check if such a group already exists and remove it. */
- if (g_hash_table_lookup (session->priv->groups, group->name)) {
- g_hash_table_remove (session->priv->groups, group->name);
- }
-
+ /* insert the group, g_hash_table_insert 'll remove it first if it already exists */
g_hash_table_insert (session->priv->groups,
g_strdup (group->name), group);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]