[PATCH] plug some memory leaks on normal operation

Guillem Jover guillem.jover at nokia.com
Fri Feb 13 10:36:46 PST 2009


Some pointers were being lost when being overwritten by new values,
others were just not being freed.
---
 hald/create_cache.c   |    1 +
 hald/hald_dbus.c      |    6 +++++-
 hald/linux/blockdev.c |    1 +
 partutil/partutil.c   |    4 +++-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hald/create_cache.c b/hald/create_cache.c
index f2e5917..ed42b7f 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -703,6 +703,7 @@ di_rules_init (void)
 		HAL_INFO (("Generating rules done (occupying %d bytes)", header.all_rules_size));
 	}
 
+	g_free (cachename_temp);
 	return num_skipped_fdi_files;
 error:
 	HAL_ERROR (("Error generating fdi cache"));
diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index 697fb75..c0cb8c2 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -4158,8 +4158,12 @@ hald_exec_method_cb (HalDevice *d, guint32 exit_type,
 		dbus_message_unref (reply);
 	} else if (exp_name != NULL && exp_detail != NULL) {
 		if (!is_valid_interface_name (exp_name)) {
-			exp_detail = g_strconcat (exp_name, " \n ", exp_detail, NULL);
+			gchar *old_detail = exp_detail;
+
+			exp_detail = g_strconcat (exp_name, " \n ", old_detail, NULL);
 			exp_name = "org.freedesktop.Hal.Device.UnknownError";
+
+			g_free (old_detail);
 		}
 		reply = dbus_message_new_error (message, exp_name, exp_detail);
                 if (reply == NULL) {
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index ec4e405..3fbb51a 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -967,6 +967,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					link = g_strdup_printf ("%s/%s", path, dp->d_name);
 					target = resolve_symlink (link);
 					HAL_INFO ((" %s -> %s", link, target));
+					g_free (link);
 
 					if (target != NULL) {
 						HalDevice *slave_volume;
diff --git a/partutil/partutil.c b/partutil/partutil.c
index 42280af..3f0ec61 100644
--- a/partutil/partutil.c
+++ b/partutil/partutil.c
@@ -719,8 +719,10 @@ part_table_parse_gpt (int fd, guint64 offset, guint64 size)
 
 		partition_type_guid = get_le_guid (gpt_part_entry.partition_type_guid);
 
-		if (strcmp (partition_type_guid, GPT_PART_TYPE_GUID_EMPTY) == 0)
+		if (strcmp (partition_type_guid, GPT_PART_TYPE_GUID_EMPTY) == 0) {
+			g_free (partition_type_guid);
 			continue;
+		}
 
 		pe = part_entry_new (NULL,
 				     (guint8*) &gpt_part_entry,
-- 
1.6.0.2



More information about the hal mailing list