[PATCH] do not leak on error conditions
Guillem Jover
guillem.jover at nokia.com
Fri Feb 13 10:36:26 PST 2009
---
hald/create_cache.c | 1 +
hald/device_info.c | 1 +
hald/linux/addons/addon-hid-ups.c | 3 ++-
hald/linux/addons/addon-input.c | 2 ++
libhal/libhal.c | 4 +++-
5 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/hald/create_cache.c b/hald/create_cache.c
index 232fe98..f2e5917 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -479,6 +479,7 @@ rules_add_fdi_file (const char *filename, int fd)
parser = XML_ParserCreate (NULL);
if (parser == NULL) {
HAL_ERROR (("Couldn't allocate memory for parser"));
+ g_free (fdi_ctx);
goto out;
}
XML_SetUserData (parser, fdi_ctx);
diff --git a/hald/device_info.c b/hald/device_info.c
index e378a2e..6444b54 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -852,6 +852,7 @@ handle_merge (struct rule *rule, HalDevice *d)
if (d == NULL) {
HAL_ERROR (("Could not find device with udi '%s'", udi_to_merge));
+ g_free (key);
return FALSE;
}
}
diff --git a/hald/linux/addons/addon-hid-ups.c b/hald/linux/addons/addon-hid-ups.c
index 31f3803..b18e1bc 100644
--- a/hald/linux/addons/addon-hid-ups.c
+++ b/hald/linux/addons/addon-hid-ups.c
@@ -274,7 +274,6 @@ ups_get_static (LibHalContext *ctx, const char *udi, int fd,
dbus_error_init (&error);
libhal_device_commit_changeset (ctx, cs, &error);
- libhal_device_free_changeset (cs);
dbus_error_init (&error);
libhal_device_add_capability (ctx, udi, "battery", &error);
@@ -282,6 +281,8 @@ ups_get_static (LibHalContext *ctx, const char *udi, int fd,
ret = TRUE;
out:
+ libhal_device_free_changeset (cs);
+
return ret;
}
diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 5704f82..f6935d3 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -357,6 +357,7 @@ add_device (LibHalContext *ctx,
if ((device_file = libhal_ps_get_string (properties, "input.device")) == NULL) {
HAL_ERROR(("%s has no property input.device", udi));
+ g_free (data);
return;
}
@@ -369,6 +370,7 @@ add_device (LibHalContext *ctx,
eventfp = open(device_file, O_RDONLY | O_NONBLOCK);
if (!eventfp) {
HAL_ERROR(("Unable to open %s for reading", device_file));
+ g_free (data);
return;
}
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 08c5481..855b9dc 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -476,8 +476,10 @@ get_property_set (DBusMessageIter *iter)
p->type = (LibHalPropertyType) dbus_message_iter_get_arg_type (&var_iter);
- if(!libhal_property_fill_value_from_variant (p, &var_iter))
+ if (!libhal_property_fill_value_from_variant (p, &var_iter)) {
+ free (p);
goto oom;
+ }
HASH_ADD_KEYPTR (hh, result->properties, p->key, strlen (p->key), p);
--
1.6.0.2
More information about the hal
mailing list