summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-10-22 12:31:59 +0200
committerThomas Haller <thaller@redhat.com>2013-10-22 19:53:46 +0200
commite670528778d0034693eabb140f1f2709e5e78a3a (patch)
tree03fcf6b60887780278a5967172e978c5a97b5b8a
parent5a0d3c724d16a9c51bb62bf0a117549022a32646 (diff)
downloadNetworkManager-e670528778d0034693eabb140f1f2709e5e78a3a.tar.gz
dispatcher: fix memory leak in nm-dispatcher-action
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--callouts/nm-dispatcher-action.c8
-rw-r--r--include/nm-gvaluearray-compat.h16
2 files changed, 15 insertions, 9 deletions
diff --git a/callouts/nm-dispatcher-action.c b/callouts/nm-dispatcher-action.c
index a9ed37ada2..d37a08e1b2 100644
--- a/callouts/nm-dispatcher-action.c
+++ b/callouts/nm-dispatcher-action.c
@@ -134,9 +134,10 @@ request_free (Request *request)
g_free (request->action);
g_free (request->iface);
g_strfreev (request->envp);
- if (request->scripts)
+ if (request->scripts) {
g_ptr_array_foreach (request->scripts, (GFunc) script_info_free, NULL);
- g_ptr_array_free (request->scripts, TRUE);
+ g_ptr_array_free (request->scripts, TRUE);
+ }
}
static gboolean
@@ -172,7 +173,7 @@ next_script (gpointer user_data)
}
/* All done */
- results = g_ptr_array_sized_new (request->scripts->len);
+ results = g_ptr_array_new_full (request->scripts->len, (GDestroyNotify) g_value_array_free);
for (i = 0; i < request->scripts->len; i++) {
ScriptInfo *script = g_ptr_array_index (request->scripts, i);
GValue elt = G_VALUE_INIT;
@@ -203,6 +204,7 @@ next_script (gpointer user_data)
dbus_g_method_return (request->context, results);
request_free (request);
+ g_ptr_array_unref (results);
return FALSE;
}
diff --git a/include/nm-gvaluearray-compat.h b/include/nm-gvaluearray-compat.h
index 35d6b86769..e26ce37174 100644
--- a/include/nm-gvaluearray-compat.h
+++ b/include/nm-gvaluearray-compat.h
@@ -44,12 +44,16 @@
G_GNUC_END_IGNORE_DEPRECATIONS \
})
-#define g_value_array_free(value_array) \
- G_GNUC_EXTENSION ({ \
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- g_value_array_free (value_array); \
- G_GNUC_END_IGNORE_DEPRECATIONS \
- })
+static inline void
+__g_value_array_free (GValueArray *value_array)
+{
+ G_GNUC_EXTENSION ({
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ g_value_array_free (value_array);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ });
+}
+#define g_value_array_free __g_value_array_free
#define g_value_array_copy(value_array) \
G_GNUC_EXTENSION ({ \