summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Pierre Bogler <jean-pierre.bogler@continental-corporation.com>2015-03-06 18:23:29 +0100
committerJean-Pierre Bogler <jean-pierre.bogler@continental-corporation.com>2015-03-06 18:23:29 +0100
commit401cca51de36c668cd81cb44161e52fb7db50266 (patch)
tree61b3e2b98b47b3f6b7959cc5d897b9a531ac103c
parente8ec4787395986599cc2c816ac2bbe56d3c85764 (diff)
downloadnode-health-monitor-401cca51de36c668cd81cb44161e52fb7db50266.tar.gz
Fixed leaks from "g_variant_get_child_value" calls1.3.4
Fixed memory leaks. The children returned by "g_variant_get_child_value" were not freed. Instead of "g_variant_get_child_value", "g_variant_get_child" now is used at most places in nhm_systemd.c Change-Id: Ic2a0c06ca743b7c7b26c958ed90d56d30a90c839
-rw-r--r--ChangeLog5
-rw-r--r--NEWS4
-rw-r--r--configure.ac2
-rw-r--r--src/nhm-systemd.c22
4 files changed, 17 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 094c1f4..738b201 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+19th Nov 2013 Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com>
+ * Fixed memory leaks. The children returned by "g_variant_get_child_value" were
+ not freed. Instead of "g_variant_get_child_value", "g_variant_get_child" now
+ is used at most places in nhm_systemd.c
+
23rd Oct 2013 Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com>
* Bugfix for crash at startup. If a service failed before dbus connection was
obtained, a sgementation fault occured in "nhm_main_register_app_status".
diff --git a/NEWS b/NEWS
index 46b6119..99221fd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+1.3.4
+=====
+* Bugfix for memory leak in systemd observation
+
1.3.3
=====
* Two bugfixes for start up and error cases
diff --git a/configure.ac b/configure.ac
index ee8facf..1fe13c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@
################################################################################
# Initialize autoconf
-AC_INIT([node-health-monitor], [1.3.3])
+AC_INIT([node-health-monitor], [1.3.4])
AC_PREREQ([2.50])
AC_COPYRIGHT([Copyright (c) 2013 Continental Automotive GmbH])
diff --git a/src/nhm-systemd.c b/src/nhm-systemd.c
index 1170631..2510c8b 100644
--- a/src/nhm-systemd.c
+++ b/src/nhm-systemd.c
@@ -411,7 +411,6 @@ nhm_systemd_unit_get_active_state(NhmSystemdUnit *unit)
{
GError *error = NULL;
GVariant *propval = NULL;
- GVariant *child = NULL;
const gchar *state = NULL;
NhmActiveState retval = NHM_ACTIVE_STATE_UNKNOWN;
@@ -431,8 +430,7 @@ nhm_systemd_unit_get_active_state(NhmSystemdUnit *unit)
if(error == NULL)
{
- child = g_variant_get_child_value(propval, 0);
- state = g_variant_get_string(child, NULL);
+ g_variant_get_child(propval, 0, "&s", &state);
retval = nhm_systemd_active_state_string_to_enum(state);
g_variant_unref(propval);
}
@@ -476,7 +474,6 @@ nhm_systemd_unit_added(GDBusConnection *connection,
{
NhmSystemdUnit *unit = NULL;
const gchar *param_type = NULL;
- GVariant *child = NULL;
NhmSystemdUnit search_unit;
GSList *list_item = NULL;
@@ -484,8 +481,7 @@ nhm_systemd_unit_added(GDBusConnection *connection,
if(g_strcmp0(param_type, "(so)") == 0)
{
- child = g_variant_get_child_value(parameters, 0);
- search_unit.name = (gchar*) g_variant_get_string(child, NULL);
+ g_variant_get_child(parameters, 0, "&s", &search_unit.name);
if(g_str_has_suffix(search_unit.name, ".service") == TRUE)
{
@@ -497,8 +493,7 @@ nhm_systemd_unit_added(GDBusConnection *connection,
unit = g_new(NhmSystemdUnit, 1);
unit->name = g_strdup(search_unit.name);
- child = g_variant_get_child_value(parameters, 1);
- unit->path = g_variant_dup_string(child, NULL);
+ g_variant_get_child(parameters, 1, "s", &unit->path);
unit->active_state = nhm_systemd_unit_get_active_state(unit);
unit->sig_sub_id = nhm_systemd_subscribe_properties_changed(unit);
@@ -548,15 +543,13 @@ nhm_systemd_unit_removed(GDBusConnection *connection,
{
GSList *list_item = NULL;
const gchar *param_type = NULL;
- GVariant *child = NULL;
NhmSystemdUnit search_unit;
param_type = g_variant_get_type_string(parameters);
if(g_strcmp0(param_type, "(so)") == 0)
{
- child = g_variant_get_child_value(parameters, 0);
- search_unit.name = (gchar*) g_variant_get_string(child, NULL);
+ g_variant_get_child(parameters, 0, "&s", &search_unit.name);
if(g_str_has_suffix(search_unit.name, ".service") == TRUE)
{
@@ -620,8 +613,7 @@ nhm_systemd_unit_properties_changed(GDBusConnection *connection,
if(g_strcmp0(param_type, "(sa{sv}as)") == 0)
{
- inv_props = g_variant_get_strv(g_variant_get_child_value(parameters, 2),
- NULL);
+ g_variant_get_child(parameters, 2, "^a&s", &inv_props);
if(nhm_helper_str_in_strv("ActiveState", (gchar**) inv_props) == TRUE)
{
@@ -810,8 +802,7 @@ nhm_systemd_connect(NhmSystemdAppStatusCb app_status_cb)
new_unit = g_new(NhmSystemdUnit, 1);
new_unit->name = unit_name;
- active_state =
- g_variant_get_string(g_variant_get_child_value(unit, 3), NULL);
+ g_variant_get_child(unit, 3, "&s", &active_state);
new_unit->active_state =
nhm_systemd_active_state_string_to_enum(active_state);
@@ -830,6 +821,7 @@ nhm_systemd_connect(NhmSystemdAppStatusCb app_status_cb)
}
}
+ g_variant_unref(unit_array);
g_variant_unref(manager_return);
}
else