From da6256ac92440808970712f8a0017cf39d6afa91 Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Mon, 28 Jan 2008 18:44:45 -0800 Subject: [PATCH] [Config] Fix memory leak on failure This fixes a small memory leak that would happen when the configuration system could not find a value in both the user preferences, and in the default configuration. A GValue was leaked for each value that could not be found. --- tilda-config.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tilda-config.c b/tilda-config.c index 6563312..54a3d50 100644 --- a/tilda-config.c +++ b/tilda-config.c @@ -190,7 +190,7 @@ tilda_controller_set_property_from_config (TildaController *self, const gchar *p gboolean ret; GParamSpec *pspec; - GValue *value = g_malloc0(sizeof(GValue)); + GValue *value = g_new0 (GValue, 1); gboolean (*parse_func) (GKeyFile *keyfile, const gchar *group_name, const gchar *key, GValue *value, GError **error); /* Get the pspec for this property */ @@ -270,6 +270,7 @@ tilda_controller_set_property_from_config (TildaController *self, const gchar *p //failure: g_critical (_("Unable to find a value for controller property: %s\n"), property); + g_free (value); return FALSE; success: @@ -290,7 +291,7 @@ tilda_window_set_property_from_config (TildaWindow *self, const gchar *property) gboolean ret; GParamSpec *pspec; - GValue *value = g_malloc0(sizeof(GValue)); + GValue *value = g_new0(GValue, 1); gboolean (*parse_func) (GKeyFile *keyfile, const gchar *group_name, const gchar *key, GValue *value, GError **error); /* Get the pspec for this property */ @@ -372,6 +373,7 @@ tilda_window_set_property_from_config (TildaWindow *self, const gchar *property) //failure: g_critical (_("Unable to find a value for window property: %s\n"), property); + g_free (value); return FALSE; success: @@ -393,7 +395,7 @@ tilda_terminal_set_property_from_config (TildaTerminal *self, const gchar *prope gboolean ret; GParamSpec *pspec; - GValue *value = g_malloc0(sizeof(GValue)); + GValue *value = g_new0 (GValue, 1); gboolean (*parse_func) (GKeyFile *keyfile, const gchar *group_name, const gchar *key, GValue *value, GError **error); /* Get the pspec for this property */ @@ -490,6 +492,7 @@ tilda_terminal_set_property_from_config (TildaTerminal *self, const gchar *prope //failure: g_critical (_("Unable to find a value for terminal property: %s\n"), property); + g_free (value); return FALSE; success: -- 2.34.1