[goffice] GOConf: plug leaks.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOConf: plug leaks.
- Date: Sun, 28 Oct 2012 21:02:17 +0000 (UTC)
commit 2d4753ae4315f7b33abcebcd2f132cc4f0ee59ec
Author: Morten Welinder <terra gnome org>
Date: Sun Oct 28 17:02:04 2012 -0400
GOConf: plug leaks.
ChangeLog | 3 +++
goffice/app/go-conf-gsettings.c | 28 ++++++++++++++++++----------
2 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 07f45c0..5f813ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2012-10-28 Morten Welinder <terra gnome org>
+ * goffice/app/go-conf-gsettings.c (go_conf_free_node): plug leak.
+ (go_conf_get_node): Plug leak.
+
* goffice/graph/gog-theme.c (gog_theme_finalize): Get rid of ->dcm
too.
diff --git a/goffice/app/go-conf-gsettings.c b/goffice/app/go-conf-gsettings.c
index 284fa15..803303a 100644
--- a/goffice/app/go-conf-gsettings.c
+++ b/goffice/app/go-conf-gsettings.c
@@ -104,9 +104,10 @@ go_conf_get_node (GOConfNode *parent, gchar const *key)
char *last_dot = strrchr (node->id, '.');
*last_dot = 0;
node->settings = g_hash_table_lookup (installed_schemas, node->id)? g_settings_new (node->id): NULL;
- if (node->settings)
+ if (node->settings) {
+ g_free (node->key);
node->key = g_strdup (last_dot + 1);
- else {
+ } else {
go_conf_free_node (node);
node = NULL;
}
@@ -117,14 +118,21 @@ go_conf_get_node (GOConfNode *parent, gchar const *key)
void
go_conf_free_node (GOConfNode *node)
{
- if (node && node->ref_count-- > 1) {
- if (node->settings)
- g_object_unref (node->settings);
- g_free (node->path);
- g_free (node->id);
- g_free (node->key);
- g_free (node);
- }
+ if (!node)
+ return;
+
+ g_return_if_fail (node->ref_count > 0);
+
+ node->ref_count--;
+ if (node->ref_count > 0)
+ return;
+
+ if (node->settings)
+ g_object_unref (node->settings);
+ g_free (node->path);
+ g_free (node->id);
+ g_free (node->key);
+ g_free (node);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]