dispatcher: fix memory leak in nm-dispatcher-action

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2013-10-22 12:31:59 +02:00
parent 5a0d3c724d
commit e670528778
2 changed files with 15 additions and 9 deletions

View file

@ -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;
}

View file

@ -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 ({ \